<?php
function benchmarkMemory(callable $function, $args=null)
{
$memory = memory_get_peak_usage();
$result = is_array($args)?
call_user_func_array($function, $args):
call_user_func_array($function);
return [
'memory' => memory_get_peak_usage() - $memory
];
}
var_dump(benchmarkMemory('str_repeat', ['test',1E4]));
gc_collect_cycles();
var_dump(benchmarkMemory('str_repeat', ['test',1E3]));
- Output for 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- array(1) {
["memory"]=>
int(4056)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 8.1.0 - 8.1.31
- array(1) {
["memory"]=>
int(4384)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 8.0.0 - 8.0.30
- array(1) {
["memory"]=>
int(3760)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 7.4.0 - 7.4.33
- array(1) {
["memory"]=>
int(3888)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 7.3.12 - 7.3.33
- array(1) {
["memory"]=>
int(4008)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 7.2.6 - 7.2.33
- array(1) {
["memory"]=>
int(4688)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 7.1.0, 7.1.7 - 7.1.20
- array(1) {
["memory"]=>
int(5008)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 7.1.5 - 7.1.6
- array(1) {
["memory"]=>
int(5456)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 7.0.0 - 7.0.20
- array(1) {
["memory"]=>
int(5384)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28
- array(1) {
["memory"]=>
int(35984)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 5.4.0 - 5.4.45
- array(1) {
["memory"]=>
int(36064)
}
array(1) {
["memory"]=>
int(0)
}
- Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/0ifv8 on line 8
Process exited with code 255. - Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
- <br />
<b>Parse error</b>: syntax error, unexpected '[' in <b>/in/0ifv8</b> on line <b>8</b><br />
Process exited with code 255. - Output for 5.0.0 - 5.0.5
- <br />
<b>Parse error</b>: parse error, unexpected '[' in <b>/in/0ifv8</b> on line <b>8</b><br />
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- <br />
<b>Parse error</b>: syntax error, unexpected T_STRING, expecting ')' in <b>/in/0ifv8</b> on line <b>2</b><br />
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- <br />
<b>Parse error</b>: parse error, unexpected T_STRING, expecting ')' in <b>/in/0ifv8</b> on line <b>2</b><br />
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- <br />
<b>Parse error</b>: parse error, expecting `')'' in <b>/in/0ifv8</b> on line <b>2</b><br />
Process exited with code 255.
preferences:
47.04 ms | 429 KiB | 5 Q