com php-src: add test for eb32da13: Zend/tests/implode_small _strings.phpt
| From: | Anatol Belski | Date: | Mon, 09 Nov 2015 21:45:22 +0000 |
| Subject: | com php-src: add test for eb32da13: Zend/tests/implode_small _strings.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89717@lists.php.net to get a copy of this message | ||
Commit: 2e38918ba41a9c8b5767f93c29e172fbfb97b3fe
Author: Anatol Belski <ab@php.net> Mon, 9 Nov 2015 22:45:22 +0100
Parents: c9eacb181cc2fe4c05e69a3231eae728cd232bfa
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2e38918ba41a9c8b5767f93c29e172fbfb97b3fe
Log:
add test for eb32da13
Changed paths:
A Zend/tests/implode_small_strings.phpt
Diff:
diff --git a/Zend/tests/implode_small_strings.phpt b/Zend/tests/implode_small_strings.phpt
new file mode 100644
index 0000000..94652a6
--- /dev/null
+++ b/Zend/tests/implode_small_strings.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Implode many small strings should not slowdown allocations
+--INI--
+memory_limit=256m
+--FILE--
+<?php
+
+/* To note is that memory usage can vary depending on whether opcache is on. The actual
+ measuring that matters is timing here. */
+
+$time = microtime(TRUE);
+
+/* This might vary on Linux/Windows, so the worst case and also count in slow machines. */
+$t0_max = 0.1;
+$t1_max = 0.5;
+
+$datas = [];
+for ($i = 0; $i < 220000; $i++)
+{
+ $datas[] = [
+ '000.000.000.000',
+ '000.255.255.255',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ ];
+}
+
+$t0 = microtime(TRUE) - $time;
+var_dump($t0 < $t0_max);
+
+
+$texts = '';
+foreach ($datas AS $data)
+{
+ $texts .= implode("\t", $data) . "\r\n";
+}
+
+$t1 = microtime(TRUE) - $time;
+var_dump($t1 < $t1_max);
+
+?>
++++DONE+++
+--EXPECT--
+bool(true)
+bool(true)
++++DONE+++