3v4l.org

run code in 300+ PHP versions simultaneously
<?php function benchmark(callable $function, $args=null, $count=1) { $time = microtime(1); for($i=0; $i<$count; $i++) { $result = is_array($args)? call_user_func_array($function, $args): call_user_func_array($function); } return array( 'total_time' => microtime(1) - $time, 'average_time' => (microtime(1) - $time)/$count, 'count' => $count ); } function p($string) { print_r($string . "<br>"); } var_dump(benchmark('p', array('test',1E4))); gc_collect_cycles(); //var_dump(benchmark('p', array('test',1E3)));
Output for 7.2.3, 7.4.0
test<br>array(3) { ["total_time"]=> float(3.4093856811523E-5) ["average_time"]=> float(3.504753112793E-5) ["count"]=> int(1) }
Output for 7.3.12
test<br>array(3) { ["total_time"]=> float(2.598762512207E-5) ["average_time"]=> float(3.3140182495117E-5) ["count"]=> int(1) }
Output for 7.3.11
test<br>array(3) { ["total_time"]=> float(3.9100646972656E-5) ["average_time"]=> float(4.1007995605469E-5) ["count"]=> int(1) }
Output for 7.3.10
test<br>array(3) { ["total_time"]=> float(3.0994415283203E-5) ["average_time"]=> float(3.1948089599609E-5) ["count"]=> int(1) }
Output for 7.3.9
test<br>array(3) { ["total_time"]=> float(2.288818359375E-5) ["average_time"]=> float(2.7894973754883E-5) ["count"]=> int(1) }
Output for 7.3.8
test<br>array(3) { ["total_time"]=> float(2.5033950805664E-5) ["average_time"]=> float(3.0994415283203E-5) ["count"]=> int(1) }
Output for 7.3.7
test<br>array(3) { ["total_time"]=> float(2.9087066650391E-5) ["average_time"]=> float(3.4093856811523E-5) ["count"]=> int(1) }
Output for 7.3.6
test<br>array(3) { ["total_time"]=> float(3.7908554077148E-5) ["average_time"]=> float(4.4107437133789E-5) ["count"]=> int(1) }
Output for 7.2.7, 7.3.5
test<br>array(3) { ["total_time"]=> float(3.0040740966797E-5) ["average_time"]=> float(3.6001205444336E-5) ["count"]=> int(1) }
Output for 7.3.4
test<br>array(3) { ["total_time"]=> float(2.3126602172852E-5) ["average_time"]=> float(2.8133392333984E-5) ["count"]=> int(1) }
Output for 7.3.3
test<br>array(3) { ["total_time"]=> float(2.7894973754883E-5) ["average_time"]=> float(3.6954879760742E-5) ["count"]=> int(1) }
Output for 7.3.2
test<br>array(3) { ["total_time"]=> float(3.3140182495117E-5) ["average_time"]=> float(4.3153762817383E-5) ["count"]=> int(1) }
Output for 7.3.1
test<br>array(3) { ["total_time"]=> float(2.3126602172852E-5) ["average_time"]=> float(3.0040740966797E-5) ["count"]=> int(1) }
Output for 7.3.0
test<br>array(3) { ["total_time"]=> float(2.8133392333984E-5) ["average_time"]=> float(3.504753112793E-5) ["count"]=> int(1) }
Output for 7.2.25
test<br>array(3) { ["total_time"]=> float(5.1021575927734E-5) ["average_time"]=> float(5.2928924560547E-5) ["count"]=> int(1) }
Output for 7.2.24
test<br>array(3) { ["total_time"]=> float(4.0054321289062E-5) ["average_time"]=> float(4.1007995605469E-5) ["count"]=> int(1) }
Output for 7.2.23
test<br>array(3) { ["total_time"]=> float(3.504753112793E-5) ["average_time"]=> float(4.1007995605469E-5) ["count"]=> int(1) }
Output for 7.2.14, 7.2.22
test<br>array(3) { ["total_time"]=> float(3.504753112793E-5) ["average_time"]=> float(3.6001205444336E-5) ["count"]=> int(1) }
Output for 7.2.21
test<br>array(3) { ["total_time"]=> float(3.0994415283203E-5) ["average_time"]=> float(3.2901763916016E-5) ["count"]=> int(1) }
Output for 7.2.20
test<br>array(3) { ["total_time"]=> float(3.1948089599609E-5) ["average_time"]=> float(3.6954879760742E-5) ["count"]=> int(1) }
Output for 7.2.19
test<br>array(3) { ["total_time"]=> float(5.1975250244141E-5) ["average_time"]=> float(5.3882598876953E-5) ["count"]=> int(1) }
Output for 7.2.18
test<br>array(3) { ["total_time"]=> float(3.0994415283203E-5) ["average_time"]=> float(3.6001205444336E-5) ["count"]=> int(1) }
Output for 5.4.43, 5.5.11, 5.5.21, 7.2.17
test<br>array(3) { ["total_time"]=> float(2.598762512207E-5) ["average_time"]=> float(2.6941299438477E-5) ["count"]=> int(1) }
Output for 7.2.16
test<br>array(3) { ["total_time"]=> float(2.6941299438477E-5) ["average_time"]=> float(2.6941299438477E-5) ["count"]=> int(1) }
Output for 7.2.15
test<br>array(3) { ["total_time"]=> float(2.7179718017578E-5) ["average_time"]=> float(2.8133392333984E-5) ["count"]=> int(1) }
Output for 7.2.13
test<br>array(3) { ["total_time"]=> float(2.7894973754883E-5) ["average_time"]=> float(3.6001205444336E-5) ["count"]=> int(1) }
Output for 5.4.31, 5.4.41, 7.2.12
test<br>array(3) { ["total_time"]=> float(2.7894973754883E-5) ["average_time"]=> float(2.9087066650391E-5) ["count"]=> int(1) }
Output for 7.2.11
test<br>array(3) { ["total_time"]=> float(4.3869018554688E-5) ["average_time"]=> float(5.1021575927734E-5) ["count"]=> int(1) }
Output for 7.2.10
test<br>array(3) { ["total_time"]=> float(2.598762512207E-5) ["average_time"]=> float(3.0994415283203E-5) ["count"]=> int(1) }
Output for 7.2.9
test<br>array(3) { ["total_time"]=> float(2.8848648071289E-5) ["average_time"]=> float(3.3855438232422E-5) ["count"]=> int(1) }
Output for 7.2.8
test<br>array(3) { ["total_time"]=> float(2.7179718017578E-5) ["average_time"]=> float(3.2186508178711E-5) ["count"]=> int(1) }
Output for 7.2.6
test<br>array(3) { ["total_time"]=> float(3.6954879760742E-5) ["average_time"]=> float(4.2915344238281E-5) ["count"]=> int(1) }
Output for 7.2.5
test<br>array(3) { ["total_time"]=> float(3.9100646972656E-5) ["average_time"]=> float(4.0054321289062E-5) ["count"]=> int(1) }
Output for 7.2.4
test<br>array(3) { ["total_time"]=> float(4.3153762817383E-5) ["average_time"]=> float(4.4107437133789E-5) ["count"]=> int(1) }
Output for 7.2.1 - 7.2.2
test<br>array(3) { ["total_time"]=> float(3.6954879760742E-5) ["average_time"]=> float(3.7908554077148E-5) ["count"]=> int(1) }
Output for 7.2.0
test<br>array(3) { ["total_time"]=> float(2.4795532226562E-5) ["average_time"]=> float(2.8848648071289E-5) ["count"]=> int(1) }
Output for 7.1.33
test<br>array(3) { ["total_time"]=> float(2.288818359375E-5) ["average_time"]=> float(2.4080276489258E-5) ["count"]=> int(1) }
Output for 5.4.39, 7.0.20, 7.1.30, 7.1.32
test<br>array(3) { ["total_time"]=> float(2.1934509277344E-5) ["average_time"]=> float(2.288818359375E-5) ["count"]=> int(1) }
Output for 7.1.31
test<br>array(3) { ["total_time"]=> float(3.4093856811523E-5) ["average_time"]=> float(3.6001205444336E-5) ["count"]=> int(1) }
Output for 7.1.29
test<br>array(3) { ["total_time"]=> float(4.1961669921875E-5) ["average_time"]=> float(4.4107437133789E-5) ["count"]=> int(1) }
Output for 5.4.24, 5.4.27, 5.4.35, 5.4.40, 5.4.45, 5.5.6, 5.5.18, 5.5.29, 5.6.1, 5.6.4 - 5.6.5, 5.6.12, 7.1.27 - 7.1.28
test<br>array(3) { ["total_time"]=> float(2.4080276489258E-5) ["average_time"]=> float(2.5033950805664E-5) ["count"]=> int(1) }
Output for 5.5.8, 5.6.13, 7.1.26
test<br>array(3) { ["total_time"]=> float(1.8835067749023E-5) ["average_time"]=> float(2.0027160644531E-5) ["count"]=> int(1) }
Output for 5.5.32, 7.1.25
test<br>array(3) { ["total_time"]=> float(2.598762512207E-5) ["average_time"]=> float(2.7894973754883E-5) ["count"]=> int(1) }
Output for 5.4.2, 5.4.4, 5.4.15 - 5.4.16, 7.1.7
test<br>array(3) { ["total_time"]=> float(1.4066696166992E-5) ["average_time"]=> float(1.5020370483398E-5) ["count"]=> int(1) }
Output for 7.1.6
test<br>array(3) { ["total_time"]=> float(2.9802322387695E-5) ["average_time"]=> float(3.1948089599609E-5) ["count"]=> int(1) }
Output for 7.1.5
test<br>array(3) { ["total_time"]=> float(3.3855438232422E-5) ["average_time"]=> float(3.4809112548828E-5) ["count"]=> int(1) }
Output for 5.4.17, 5.4.25, 7.0.4, 7.1.0
test<br>array(3) { ["total_time"]=> float(1.6927719116211E-5) ["average_time"]=> float(1.7881393432617E-5) ["count"]=> int(1) }
Output for 5.4.21, 5.4.34, 5.5.35, 5.6.17 - 5.6.18, 7.0.3, 7.0.14
test<br>array(3) { ["total_time"]=> float(1.9073486328125E-5) ["average_time"]=> float(2.0027160644531E-5) ["count"]=> int(1) }
Output for 5.5.1, 7.0.12
test<br>array(3) { ["total_time"]=> float(1.5020370483398E-5) ["average_time"]=> float(1.6212463378906E-5) ["count"]=> int(1) }
Output for 5.4.8, 7.0.1, 7.0.6
test<br>array(3) { ["total_time"]=> float(1.7881393432617E-5) ["average_time"]=> float(1.8835067749023E-5) ["count"]=> int(1) }
Output for 7.0.5
test<br>array(3) { ["total_time"]=> float(1.3113021850586E-5) ["average_time"]=> float(1.3113021850586E-5) ["count"]=> int(1) }
Output for 5.4.0, 5.4.3, 5.4.11 - 5.4.14, 5.4.19, 7.0.2
test<br>array(3) { ["total_time"]=> float(1.5020370483398E-5) ["average_time"]=> float(1.5974044799805E-5) ["count"]=> int(1) }
Output for 7.0.0
test<br>array(3) { ["total_time"]=> float(1.4066696166992E-5) ["average_time"]=> float(1.4066696166992E-5) ["count"]=> int(1) }
Output for 5.6.28
test<br>array(3) { ["total_time"]=> float(2.3841857910156E-5) ["average_time"]=> float(2.598762512207E-5) ["count"]=> int(1) }
Output for 5.6.21
test<br>array(3) { ["total_time"]=> float(2.4080276489258E-5) ["average_time"]=> float(2.6226043701172E-5) ["count"]=> int(1) }
Output for 5.6.9, 5.6.20
test<br>array(3) { ["total_time"]=> float(2.288818359375E-5) ["average_time"]=> float(2.5033950805664E-5) ["count"]=> int(1) }
Output for 5.6.2, 5.6.19
test<br>array(3) { ["total_time"]=> float(2.6941299438477E-5) ["average_time"]=> float(2.7894973754883E-5) ["count"]=> int(1) }
Output for 5.5.9, 5.5.33, 5.6.16
test<br>array(3) { ["total_time"]=> float(2.5033950805664E-5) ["average_time"]=> float(2.598762512207E-5) ["count"]=> int(1) }
Output for 5.6.15
test<br>array(3) { ["total_time"]=> float(2.0980834960938E-5) ["average_time"]=> float(2.2172927856445E-5) ["count"]=> int(1) }
Output for 5.4.5, 5.4.9, 5.5.3, 5.6.14
test<br>array(3) { ["total_time"]=> float(1.5974044799805E-5) ["average_time"]=> float(1.6927719116211E-5) ["count"]=> int(1) }
Output for 5.6.11
test<br>array(3) { ["total_time"]=> float(3.7908554077148E-5) ["average_time"]=> float(3.8862228393555E-5) ["count"]=> int(1) }
Output for 5.6.10
test<br>array(3) { ["total_time"]=> float(2.2172927856445E-5) ["average_time"]=> float(2.4080276489258E-5) ["count"]=> int(1) }
Output for 5.6.8
test<br>array(3) { ["total_time"]=> float(2.0027160644531E-5) ["average_time"]=> float(2.1934509277344E-5) ["count"]=> int(1) }
Output for 5.5.19, 5.6.7
test<br>array(3) { ["total_time"]=> float(2.5033950805664E-5) ["average_time"]=> float(2.6226043701172E-5) ["count"]=> int(1) }
Output for 5.6.6
test<br>array(3) { ["total_time"]=> float(3.1948089599609E-5) ["average_time"]=> float(3.3855438232422E-5) ["count"]=> int(1) }
Output for 5.6.3
test<br>array(3) { ["total_time"]=> float(2.4795532226562E-5) ["average_time"]=> float(2.6941299438477E-5) ["count"]=> int(1) }
Output for 5.4.23, 5.4.32, 5.5.13, 5.5.16, 5.5.20, 5.5.25, 5.6.0
test<br>array(3) { ["total_time"]=> float(2.4795532226562E-5) ["average_time"]=> float(2.598762512207E-5) ["count"]=> int(1) }
Output for 5.5.34
test<br>array(3) { ["total_time"]=> float(2.1934509277344E-5) ["average_time"]=> float(2.4080276489258E-5) ["count"]=> int(1) }
Output for 5.4.28, 5.5.31
test<br>array(3) { ["total_time"]=> float(2.4080276489258E-5) ["average_time"]=> float(2.598762512207E-5) ["count"]=> int(1) }
Output for 5.4.7, 5.5.24, 5.5.30
test<br>array(3) { ["total_time"]=> float(2.0027160644531E-5) ["average_time"]=> float(2.0980834960938E-5) ["count"]=> int(1) }
Output for 5.4.36, 5.5.28
test<br>array(3) { ["total_time"]=> float(2.5033950805664E-5) ["average_time"]=> float(2.6941299438477E-5) ["count"]=> int(1) }
Output for 5.5.26 - 5.5.27
test<br>array(3) { ["total_time"]=> float(2.288818359375E-5) ["average_time"]=> float(2.3841857910156E-5) ["count"]=> int(1) }
Output for 5.5.23
test<br>array(3) { ["total_time"]=> float(2.8133392333984E-5) ["average_time"]=> float(2.9087066650391E-5) ["count"]=> int(1) }
Output for 5.5.2, 5.5.14, 5.5.22
test<br>array(3) { ["total_time"]=> float(1.7881393432617E-5) ["average_time"]=> float(1.9073486328125E-5) ["count"]=> int(1) }
Output for 5.5.15
test<br>array(3) { ["total_time"]=> float(1.978874206543E-5) ["average_time"]=> float(2.0980834960938E-5) ["count"]=> int(1) }
Output for 5.4.26, 5.4.44, 5.5.7, 5.5.10, 5.5.12
test<br>array(3) { ["total_time"]=> float(2.3126602172852E-5) ["average_time"]=> float(2.4080276489258E-5) ["count"]=> int(1) }
Output for 5.5.5
test<br>array(3) { ["total_time"]=> float(2.5033950805664E-5) ["average_time"]=> float(2.7179718017578E-5) ["count"]=> int(1) }
Output for 5.5.4
test<br>array(3) { ["total_time"]=> float(1.8835067749023E-5) ["average_time"]=> float(1.8835067749023E-5) ["count"]=> int(1) }
Output for 5.5.0
test<br>array(3) { ["total_time"]=> float(1.3828277587891E-5) ["average_time"]=> float(1.3828277587891E-5) ["count"]=> int(1) }
Output for 5.4.22, 5.4.42
test<br>array(3) { ["total_time"]=> float(2.2172927856445E-5) ["average_time"]=> float(2.3126602172852E-5) ["count"]=> int(1) }
Output for 5.4.38
test<br>array(3) { ["total_time"]=> float(2.288818359375E-5) ["average_time"]=> float(2.4795532226562E-5) ["count"]=> int(1) }
Output for 5.4.37
test<br>array(3) { ["total_time"]=> float(2.6226043701172E-5) ["average_time"]=> float(2.7179718017578E-5) ["count"]=> int(1) }
Output for 5.4.30
test<br>array(3) { ["total_time"]=> float(2.0980834960938E-5) ["average_time"]=> float(2.3126602172852E-5) ["count"]=> int(1) }
Output for 5.4.29
test<br>array(3) { ["total_time"]=> float(3.0040740966797E-5) ["average_time"]=> float(3.1948089599609E-5) ["count"]=> int(1) }
Output for 5.4.20
test<br>array(3) { ["total_time"]=> float(2.8848648071289E-5) ["average_time"]=> float(3.0040740966797E-5) ["count"]=> int(1) }
Output for 5.4.10, 5.4.18
test<br>array(3) { ["total_time"]=> float(2.0980834960938E-5) ["average_time"]=> float(2.1934509277344E-5) ["count"]=> int(1) }
Output for 5.4.6
test<br>array(3) { ["total_time"]=> float(1.7166137695312E-5) ["average_time"]=> float(1.8119812011719E-5) ["count"]=> int(1) }
Output for 5.4.1
test<br>array(3) { ["total_time"]=> float(1.3828277587891E-5) ["average_time"]=> float(1.4781951904297E-5) ["count"]=> int(1) }
Output for 5.2.3 - 5.2.17, 5.3.0 - 5.3.29
Catchable fatal error: Argument 1 passed to benchmark() must be an instance of callable, string given, called in /in/Jls88 on line 22 and defined in /in/Jls88 on line 2
Process exited with code 255.
Output for 5.2.0 - 5.2.2
<br /> <b>Catchable fatal error</b>: Argument 1 passed to benchmark() must be an instance of callable, string given, called in /in/Jls88 on line 22 and defined in <b>/in/Jls88</b> on line <b>2</b><br />
Process exited with code 255.
Output for 5.1.1 - 5.1.6
<br /> <b>Fatal error</b>: Argument 1 passed to benchmark() must be an object of class callable, called in /in/Jls88 on line 22 and defined in <b>/in/Jls88</b> on line <b>2</b><br />
Process exited with code 255.
Output for 5.1.0
<br /> <b>Fatal error</b>: fatal flex scanner internal error--end of buffer missed in <b>/in/Jls88</b> on line <b>24</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.0.5
<br /> <b>Fatal error</b>: Argument 1 must be an object of class callable in <b>/in/Jls88</b> on line <b>2</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/Jls88</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/Jls88</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/Jls88</b> on line <b>2</b><br />
Process exited with code 255.

preferences:
213.36 ms | 401 KiB | 254 Q