<?php
$arr = array_fill(0, 1000000, 'xxxxx');
$runs = 1000;
$first = 0.0;
$second = 0.0;
for ($i =0; $i < $runs; $i++) {
$start = microtime(true);
foreach ($arr as $value) {
strpos('xxxxxxx', $value);
}
$end = microtime(true);
$first += ($end-$start);
$start = microtime(true);
foreach ($arr as &$value) {
strpos('xxxxxxx', $value);
}
$end = microtime(true);
$second += ($end-$start);
}
print "First: " . ($first/$runs) . PHP_EOL;
print "Second: " . ($second/$runs) . PHP_EOL;
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0
Process exited with code 137.- Output for 5.4.18 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
- Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/9PZkh on line 3
Process exited with code 255. - Output for 5.4.0 - 5.4.17
- Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/ptau0 on line 3
Process exited with code 255. - Output for 5.3.28 - 5.3.29
- Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/9PZkh on line 3
Process exited with code 255. - Output for 5.2.1 - 5.2.17, 5.3.0 - 5.3.27
- Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/ptau0 on line 3
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/ptau0 on line 19
Process exited with code 255. - Output for 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/ptau0 on line 19
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/ptau0 on line 19
Process exited with code 255. - Output for 4.3.0
- Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/9PZkh on line 19
Process exited with code 255.
preferences:
150.46 ms | 401 KiB | 174 Q