Skip to content

Commit 2e38918

Browse files
committed
add test for eb32da1
1 parent c9eacb1 commit 2e38918

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Zend/tests/implode_small_strings.phpt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
Implode many small strings should not slowdown allocations
3+
--INI--
4+
memory_limit=256m
5+
--FILE--
6+
<?php
7+
8+
/* To note is that memory usage can vary depending on whether opcache is on. The actual
9+
measuring that matters is timing here. */
10+
11+
$time = microtime(TRUE);
12+
13+
/* This might vary on Linux/Windows, so the worst case and also count in slow machines. */
14+
$t0_max = 0.1;
15+
$t1_max = 0.5;
16+
17+
$datas = [];
18+
for ($i = 0; $i < 220000; $i++)
19+
{
20+
$datas[] = [
21+
'000.000.000.000',
22+
'000.255.255.255',
23+
'保留地址',
24+
'保留地址',
25+
'保留地址',
26+
'保留地址',
27+
'保留地址',
28+
'保留地址',
29+
];
30+
}
31+
32+
$t0 = microtime(TRUE) - $time;
33+
var_dump($t0 < $t0_max);
34+
35+
36+
$texts = '';
37+
foreach ($datas AS $data)
38+
{
39+
$texts .= implode("\t", $data) . "\r\n";
40+
}
41+
42+
$t1 = microtime(TRUE) - $time;
43+
var_dump($t1 < $t1_max);
44+
45+
?>
46+
+++DONE+++
47+
--EXPECT--
48+
bool(true)
49+
bool(true)
50+
+++DONE+++

0 commit comments

Comments
 (0)