summaryrefslogtreecommitdiff
path: root/Zend/tests/concat_003.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-12-29 21:39:40 +0100
committerNikita Popov <nikic@php.net>2016-12-29 21:39:40 +0100
commit432660f73f929b560d5f9c3d5466e3a2aee42851 (patch)
treea3d6bbbddd11bf464abf7ac9bcb8984108307d9e /Zend/tests/concat_003.phpt
parent78675ebd9adbc050718ed5aeea6149e097334008 (diff)
downloadphp-git-432660f73f929b560d5f9c3d5466e3a2aee42851.tar.gz
Another try at making concat_003 more reliable
Use array_fill() for the array population loop -- this isn't the part that is being tested and on PHP 7.0 w/o opcache this duplicates the inner array a lot.
Diffstat (limited to 'Zend/tests/concat_003.phpt')
-rw-r--r--Zend/tests/concat_003.phpt42
1 files changed, 14 insertions, 28 deletions
diff --git a/Zend/tests/concat_003.phpt b/Zend/tests/concat_003.phpt
index 53d8d2f9a4..13c6fdc087 100644
--- a/Zend/tests/concat_003.phpt
+++ b/Zend/tests/concat_003.phpt
@@ -2,37 +2,24 @@
Concatenating many small strings should not slowdown allocations
--SKIPIF--
<?php if (PHP_DEBUG) { die ("skip debug version is slow"); } ?>
---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.3;
-$t1_max = 1.0;
-
-$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);
+$t_max = 1.0;
+
+$datas = array_fill(0, 220000, [
+ '000.000.000.000',
+ '000.255.255.255',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+ '保留地址',
+]);
$time = microtime(TRUE);
$texts = '';
@@ -41,12 +28,11 @@ foreach ($datas AS $data)
$texts .= implode("\t", $data) . "\r\n";
}
-$t1 = microtime(TRUE) - $time;
-var_dump($t1 < $t1_max);
+$t = microtime(TRUE) - $time;
+var_dump($t < $t_max);
?>
+++DONE+++
--EXPECT--
bool(true)
-bool(true)
+++DONE+++