File tree 1 file changed +14
-28
lines changed 1 file changed +14
-28
lines changed Original file line number Diff line number Diff line change 2
2
Concatenating many small strings should not slowdown allocations
3
3
--SKIPIF--
4
4
<?php if (PHP_DEBUG ) { die ("skip debug version is slow " ); } ?>
5
- --INI--
6
- memory_limit=256m
7
5
--FILE--
8
6
<?php
9
7
10
- /* To note is that memory usage can vary depending on whether opcache is on. The actual
11
- measuring that matters is timing here. */
12
-
13
8
$ time = microtime (TRUE );
14
9
15
10
/* This might vary on Linux/Windows, so the worst case and also count in slow machines. */
16
- $ t0_max = 0.3 ;
17
- $ t1_max = 1.0 ;
18
-
19
- $ datas = [];
20
- for ($ i = 0 ; $ i < 220000 ; $ i ++)
21
- {
22
- $ datas [] = [
23
- '000.000.000.000 ' ,
24
- '000.255.255.255 ' ,
25
- '保留地址 ' ,
26
- '保留地址 ' ,
27
- '保留地址 ' ,
28
- '保留地址 ' ,
29
- '保留地址 ' ,
30
- '保留地址 ' ,
31
- ];
32
- }
33
-
34
- $ t0 = microtime (TRUE ) - $ time ;
35
- var_dump ($ t0 < $ t0_max );
11
+ $ t_max = 1.0 ;
12
+
13
+ $ datas = array_fill (0 , 220000 , [
14
+ '000.000.000.000 ' ,
15
+ '000.255.255.255 ' ,
16
+ '保留地址 ' ,
17
+ '保留地址 ' ,
18
+ '保留地址 ' ,
19
+ '保留地址 ' ,
20
+ '保留地址 ' ,
21
+ '保留地址 ' ,
22
+ ]);
36
23
37
24
$ time = microtime (TRUE );
38
25
$ texts = '' ;
@@ -41,12 +28,11 @@ foreach ($datas AS $data)
41
28
$ texts .= implode ("\t" , $ data ) . "\r\n" ;
42
29
}
43
30
44
- $ t1 = microtime (TRUE ) - $ time ;
45
- var_dump ($ t1 < $ t1_max );
31
+ $ t = microtime (TRUE ) - $ time ;
32
+ var_dump ($ t < $ t_max );
46
33
47
34
?>
48
35
+++DONE+++
49
36
--EXPECT--
50
37
bool(true)
51
- bool(true)
52
38
+++DONE+++
You can’t perform that action at this time.
0 commit comments