3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $iterations = 10000; $options = array('apple', 'banana', 'carrot' ,'date', 'endive'); $color = NULL; // Fill an array with random keys. This ensures // that (a) we use the same keys, and (b) // slowness in the randomizer doesn't impact the // loops (which can happen if entropy collection kicks in) $samples = array(); for ($i = 0; $i < $iterations; ++$i) { $samples[] = $options[rand(0, 4)]; } // Test a switch statement. $start_switch = microtime(TRUE); for ($i = 0; $i < $iterations; ++$i) { $option = $samples[$i]; switch ($option) { case 'apple': $color = 'red'; break; case 'banana': $color = 'yellow'; break; case 'carrot': $color = 'orange'; break; case 'date': $color = 'brown'; break; case 'endive': $color = 'green'; break; } } $end_switch = microtime(TRUE); $total_switch = $end_switch - $start_switch; printf("Switch:\t%0.6f sec to process %d" . PHP_EOL, $total_switch, $iterations); // Test an array lookup. $start_map = microtime(TRUE); $map = array( 'apple' => 'red', 'banana' => 'yellow', 'carrot' => 'orange', 'date' => 'brown', 'endive' => 'green' ); for ($i = 0; $i < $iterations; ++$i) { $option = $samples[$i]; $color = $map[$option]; } $end_map = microtime(TRUE); $total_map = $end_map - $start_map; printf("Map:\t%0.6f sec to process %d" . PHP_EOL, $total_map, $iterations);
Output for 7.1.0
Switch: 0.000960 sec to process 10000 Map: 0.000875 sec to process 10000
Output for 7.0.14
Switch: 0.000885 sec to process 10000 Map: 0.000955 sec to process 10000
Output for 7.0.7
Switch: 0.000504 sec to process 10000 Map: 0.000443 sec to process 10000
Output for 7.0.6
Switch: 0.000783 sec to process 10000 Map: 0.000680 sec to process 10000
Output for 7.0.5
Switch: 0.000524 sec to process 10000 Map: 0.000487 sec to process 10000
Output for 7.0.4
Switch: 0.000490 sec to process 10000 Map: 0.000444 sec to process 10000
Output for 7.0.3
Switch: 0.000687 sec to process 10000 Map: 0.000596 sec to process 10000
Output for 7.0.2
Switch: 0.000725 sec to process 10000 Map: 0.000657 sec to process 10000
Output for 7.0.1
Switch: 0.000521 sec to process 10000 Map: 0.000455 sec to process 10000
Output for 7.0.0
Switch: 0.000628 sec to process 10000 Map: 0.000566 sec to process 10000
Output for hhvm-3.12.0
Switch: 0.001629 sec to process 10000 Map: 0.001229 sec to process 10000
Output for hhvm-3.10.0
Switch: 0.002093 sec to process 10000 Map: 0.001460 sec to process 10000
Output for 5.6.21
Switch: 0.001873 sec to process 10000 Map: 0.000928 sec to process 10000
Output for 5.6.20
Switch: 0.001773 sec to process 10000 Map: 0.000833 sec to process 10000
Output for 5.6.19
Switch: 0.001336 sec to process 10000 Map: 0.000632 sec to process 10000
Output for 5.6.18
Switch: 0.002053 sec to process 10000 Map: 0.001010 sec to process 10000
Output for 5.6.17
Switch: 0.001352 sec to process 10000 Map: 0.000648 sec to process 10000
Output for 5.6.16
Switch: 0.001692 sec to process 10000 Map: 0.000853 sec to process 10000
Output for 5.6.15
Switch: 0.002105 sec to process 10000 Map: 0.000894 sec to process 10000
Output for 5.6.14
Switch: 0.002159 sec to process 10000 Map: 0.000990 sec to process 10000
Output for 5.6.13
Switch: 0.001819 sec to process 10000 Map: 0.000837 sec to process 10000
Output for 5.6.12
Switch: 0.001330 sec to process 10000 Map: 0.000671 sec to process 10000
Output for 5.6.11
Switch: 0.001329 sec to process 10000 Map: 0.000602 sec to process 10000
Output for 5.6.10
Switch: 0.001828 sec to process 10000 Map: 0.000856 sec to process 10000
Output for 5.6.9
Switch: 0.001901 sec to process 10000 Map: 0.000902 sec to process 10000
Output for 5.6.8
Switch: 0.001318 sec to process 10000 Map: 0.000621 sec to process 10000
Output for 5.6.7
Switch: 0.001894 sec to process 10000 Map: 0.000877 sec to process 10000
Output for 5.5.35
Switch: 0.001316 sec to process 10000 Map: 0.000690 sec to process 10000
Output for 5.5.34
Switch: 0.002094 sec to process 10000 Map: 0.001140 sec to process 10000
Output for 5.5.33
Switch: 0.002034 sec to process 10000 Map: 0.001047 sec to process 10000
Output for 5.5.32
Switch: 0.001640 sec to process 10000 Map: 0.000872 sec to process 10000
Output for 5.5.31
Switch: 0.001352 sec to process 10000 Map: 0.000686 sec to process 10000
Output for 5.5.30
Switch: 0.002104 sec to process 10000 Map: 0.001031 sec to process 10000
Output for 5.5.29
Switch: 0.001590 sec to process 10000 Map: 0.000723 sec to process 10000
Output for 5.5.28
Switch: 0.002029 sec to process 10000 Map: 0.001023 sec to process 10000
Output for 5.5.27
Switch: 0.001578 sec to process 10000 Map: 0.000944 sec to process 10000
Output for 5.5.26
Switch: 0.002018 sec to process 10000 Map: 0.001074 sec to process 10000
Output for 5.5.25
Switch: 0.001956 sec to process 10000 Map: 0.000983 sec to process 10000
Output for 5.5.24
Switch: 0.001976 sec to process 10000 Map: 0.001010 sec to process 10000
Output for 5.4.45
Switch: 0.001955 sec to process 10000 Map: 0.000994 sec to process 10000
Output for 5.4.44
Switch: 0.001386 sec to process 10000 Map: 0.000739 sec to process 10000
Output for 5.4.43
Switch: 0.001901 sec to process 10000 Map: 0.001048 sec to process 10000
Output for 5.4.42
Switch: 0.001937 sec to process 10000 Map: 0.000979 sec to process 10000
Output for 5.4.41
Switch: 0.002035 sec to process 10000 Map: 0.001100 sec to process 10000
Output for 5.4.40
Switch: 0.001736 sec to process 10000 Map: 0.000930 sec to process 10000
Output for 5.4.39
Switch: 0.001726 sec to process 10000 Map: 0.000951 sec to process 10000
Output for 5.4.38
Switch: 0.001645 sec to process 10000 Map: 0.000865 sec to process 10000
Output for 5.4.37
Switch: 0.002127 sec to process 10000 Map: 0.001038 sec to process 10000
Output for 5.4.36
Switch: 0.001595 sec to process 10000 Map: 0.000789 sec to process 10000
Output for 5.4.35
Switch: 0.001881 sec to process 10000 Map: 0.000977 sec to process 10000
Output for 5.4.34
Switch: 0.001935 sec to process 10000 Map: 0.000888 sec to process 10000
Output for 5.4.32
Switch: 0.001592 sec to process 10000 Map: 0.000840 sec to process 10000
Output for 5.4.31
Switch: 0.001608 sec to process 10000 Map: 0.000888 sec to process 10000
Output for 5.4.30
Switch: 0.001937 sec to process 10000 Map: 0.001094 sec to process 10000
Output for 5.4.29
Switch: 0.002069 sec to process 10000 Map: 0.000950 sec to process 10000
Output for 5.4.28
Switch: 0.001575 sec to process 10000 Map: 0.000770 sec to process 10000
Output for 5.4.27
Switch: 0.001933 sec to process 10000 Map: 0.000976 sec to process 10000
Output for 5.4.26
Switch: 0.002134 sec to process 10000 Map: 0.001197 sec to process 10000
Output for 5.4.25
Switch: 0.001968 sec to process 10000 Map: 0.001052 sec to process 10000
Output for 5.4.24
Switch: 0.001886 sec to process 10000 Map: 0.001013 sec to process 10000
Output for 5.4.23
Switch: 0.001513 sec to process 10000 Map: 0.000783 sec to process 10000
Output for 5.4.22
Switch: 0.001878 sec to process 10000 Map: 0.000920 sec to process 10000
Output for 5.4.21
Switch: 0.001455 sec to process 10000 Map: 0.000744 sec to process 10000
Output for 5.4.20
Switch: 0.001952 sec to process 10000 Map: 0.001043 sec to process 10000
Output for 5.4.19
Switch: 0.001878 sec to process 10000 Map: 0.001209 sec to process 10000
Output for 5.4.18
Switch: 0.001366 sec to process 10000 Map: 0.000752 sec to process 10000
Output for 5.4.17
Switch: 0.001964 sec to process 10000 Map: 0.001064 sec to process 10000
Output for 5.4.16
Switch: 0.001762 sec to process 10000 Map: 0.000919 sec to process 10000
Output for 5.4.15
Switch: 0.001966 sec to process 10000 Map: 0.001021 sec to process 10000
Output for 5.4.14
Switch: 0.001761 sec to process 10000 Map: 0.000967 sec to process 10000
Output for 5.4.13
Switch: 0.002191 sec to process 10000 Map: 0.001080 sec to process 10000
Output for 5.4.12
Switch: 0.002029 sec to process 10000 Map: 0.001114 sec to process 10000
Output for 5.4.11
Switch: 0.001583 sec to process 10000 Map: 0.000817 sec to process 10000
Output for 5.4.10
Switch: 0.001378 sec to process 10000 Map: 0.000747 sec to process 10000
Output for 5.4.9
Switch: 0.002218 sec to process 10000 Map: 0.001254 sec to process 10000
Output for 5.4.8
Switch: 0.002401 sec to process 10000 Map: 0.001080 sec to process 10000
Output for 5.4.7
Switch: 0.002168 sec to process 10000 Map: 0.001088 sec to process 10000
Output for 5.4.6
Switch: 0.002062 sec to process 10000 Map: 0.000987 sec to process 10000
Output for 5.4.5
Switch: 0.001718 sec to process 10000 Map: 0.000886 sec to process 10000
Output for 5.4.4
Switch: 0.001486 sec to process 10000 Map: 0.000803 sec to process 10000
Output for 5.4.3
Switch: 0.001331 sec to process 10000 Map: 0.000697 sec to process 10000
Output for 5.4.2
Switch: 0.001645 sec to process 10000 Map: 0.000932 sec to process 10000
Output for 5.4.1
Switch: 0.001298 sec to process 10000 Map: 0.000684 sec to process 10000
Output for 5.4.0
Switch: 0.001615 sec to process 10000 Map: 0.000802 sec to process 10000
Output for 5.3.29
Switch: 0.002371 sec to process 10000 Map: 0.001259 sec to process 10000
Output for 5.3.28
Switch: 0.002380 sec to process 10000 Map: 0.001268 sec to process 10000
Output for 5.3.27
Switch: 0.002009 sec to process 10000 Map: 0.001166 sec to process 10000
Output for 5.3.26
Switch: 0.002350 sec to process 10000 Map: 0.001330 sec to process 10000
Output for 5.3.25
Switch: 0.002336 sec to process 10000 Map: 0.001340 sec to process 10000
Output for 5.3.24
Switch: 0.002441 sec to process 10000 Map: 0.001313 sec to process 10000
Output for 5.3.23
Switch: 0.002309 sec to process 10000 Map: 0.001292 sec to process 10000
Output for 5.3.22
Switch: 0.002672 sec to process 10000 Map: 0.001407 sec to process 10000
Output for 5.3.21
Switch: 0.002790 sec to process 10000 Map: 0.001287 sec to process 10000
Output for 5.3.20
Switch: 0.002447 sec to process 10000 Map: 0.001285 sec to process 10000
Output for 5.3.19
Switch: 0.002195 sec to process 10000 Map: 0.001094 sec to process 10000
Output for 5.3.18
Switch: 0.001892 sec to process 10000 Map: 0.001060 sec to process 10000
Output for 5.3.17
Switch: 0.001932 sec to process 10000 Map: 0.000980 sec to process 10000
Output for 5.3.16
Switch: 0.002502 sec to process 10000 Map: 0.001283 sec to process 10000
Output for 5.3.15
Switch: 0.001909 sec to process 10000 Map: 0.001018 sec to process 10000
Output for 5.3.14
Switch: 0.002496 sec to process 10000 Map: 0.001407 sec to process 10000
Output for 5.3.13
Switch: 0.002364 sec to process 10000 Map: 0.001261 sec to process 10000
Output for 5.3.12
Switch: 0.002430 sec to process 10000 Map: 0.001165 sec to process 10000
Output for 5.3.11
Switch: 0.002092 sec to process 10000 Map: 0.001113 sec to process 10000
Output for 5.3.10
Switch: 0.002376 sec to process 10000 Map: 0.001331 sec to process 10000
Output for 5.3.9
Switch: 0.002377 sec to process 10000 Map: 0.001285 sec to process 10000
Output for 5.3.8
Switch: 0.002270 sec to process 10000 Map: 0.001119 sec to process 10000
Output for 5.3.7
Switch: 0.002235 sec to process 10000 Map: 0.001202 sec to process 10000
Output for 5.3.6
Switch: 0.002274 sec to process 10000 Map: 0.001193 sec to process 10000
Output for 5.3.5
Switch: 0.002689 sec to process 10000 Map: 0.001228 sec to process 10000
Output for 5.3.4
Switch: 0.002852 sec to process 10000 Map: 0.001381 sec to process 10000
Output for 5.3.3
Switch: 0.002096 sec to process 10000 Map: 0.001126 sec to process 10000
Output for 5.3.2
Switch: 0.002271 sec to process 10000 Map: 0.001235 sec to process 10000
Output for 5.3.1
Switch: 0.002497 sec to process 10000 Map: 0.001318 sec to process 10000
Output for 5.3.0
Switch: 0.001970 sec to process 10000 Map: 0.001231 sec to process 10000
Output for 5.2.17
Switch: 0.003160 sec to process 10000 Map: 0.001923 sec to process 10000
Output for 5.2.16
Switch: 0.003421 sec to process 10000 Map: 0.001853 sec to process 10000
Output for 5.2.15
Switch: 0.003557 sec to process 10000 Map: 0.002131 sec to process 10000
Output for 5.2.14
Switch: 0.003213 sec to process 10000 Map: 0.001967 sec to process 10000
Output for 5.2.13
Switch: 0.003361 sec to process 10000 Map: 0.002169 sec to process 10000
Output for 5.2.12
Switch: 0.003202 sec to process 10000 Map: 0.001968 sec to process 10000
Output for 5.2.11
Switch: 0.003716 sec to process 10000 Map: 0.001737 sec to process 10000
Output for 5.2.10
Switch: 0.002212 sec to process 10000 Map: 0.001364 sec to process 10000
Output for 5.2.9
Switch: 0.002996 sec to process 10000 Map: 0.001902 sec to process 10000
Output for 5.2.8
Switch: 0.003562 sec to process 10000 Map: 0.002105 sec to process 10000
Output for 5.2.7
Switch: 0.003075 sec to process 10000 Map: 0.001961 sec to process 10000
Output for 5.2.6
Switch: 0.002960 sec to process 10000 Map: 0.001607 sec to process 10000
Output for 5.2.5
Switch: 0.003084 sec to process 10000 Map: 0.001889 sec to process 10000
Output for 5.2.4
Switch: 0.003601 sec to process 10000 Map: 0.002342 sec to process 10000
Output for 5.2.3
Switch: 0.003516 sec to process 10000 Map: 0.002037 sec to process 10000
Output for 5.2.2
Switch: 0.002679 sec to process 10000 Map: 0.001680 sec to process 10000
Output for 5.2.1
Switch: 0.003300 sec to process 10000 Map: 0.002018 sec to process 10000
Output for 5.2.0
Switch: 0.003728 sec to process 10000 Map: 0.001980 sec to process 10000
Output for 5.1.6
Switch: 0.003996 sec to process 10000 Map: 0.001989 sec to process 10000
Output for 5.1.5
Switch: 0.003839 sec to process 10000 Map: 0.001953 sec to process 10000
Output for 5.1.4
Switch: 0.004632 sec to process 10000 Map: 0.002257 sec to process 10000
Output for 5.1.3
Switch: 0.003803 sec to process 10000 Map: 0.001887 sec to process 10000
Output for 5.1.2
Switch: 0.003547 sec to process 10000 Map: 0.002107 sec to process 10000
Output for 5.1.1
Switch: 0.004348 sec to process 10000 Map: 0.001949 sec to process 10000
Output for 5.1.0
Switch: 0.004766 sec to process 10000 Map: 0.001943 sec to process 10000
Output for 5.0.5
Switch: 0.008047 sec to process 10000 Map: 0.005154 sec to process 10000
Output for 5.0.4
Switch: 0.009472 sec to process 10000 Map: 0.006035 sec to process 10000
Output for 5.0.3
Switch: 0.007978 sec to process 10000 Map: 0.005015 sec to process 10000
Output for 5.0.2
Switch: 0.007143 sec to process 10000 Map: 0.004568 sec to process 10000
Output for 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.007385 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.004639 sec to process 10000PHP_EOL
Output for 5.0.0
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.008644 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.005022 sec to process 10000PHP_EOL
Output for 4.4.9
Switch: 0.006381 sec to process 10000 Map: 0.003873 sec to process 10000
Output for 4.4.8
Switch: 0.005409 sec to process 10000 Map: 0.003438 sec to process 10000
Output for 4.4.7
Switch: 0.005998 sec to process 10000 Map: 0.003715 sec to process 10000
Output for 4.4.6
Switch: 0.009127 sec to process 10000 Map: 0.005377 sec to process 10000
Output for 4.4.5
Switch: 0.008608 sec to process 10000 Map: 0.005204 sec to process 10000
Output for 4.4.4
Switch: 0.007541 sec to process 10000 Map: 0.003776 sec to process 10000
Output for 4.4.3
Switch: 0.007326 sec to process 10000 Map: 0.004244 sec to process 10000
Output for 4.4.2
Switch: 0.007919 sec to process 10000 Map: 0.004945 sec to process 10000
Output for 4.4.1
Switch: 0.009174 sec to process 10000 Map: 0.005564 sec to process 10000
Output for 4.4.0
Switch: 0.007395 sec to process 10000 Map: 0.004410 sec to process 10000
Output for 4.3.11
Switch: 0.009012 sec to process 10000 Map: 0.005326 sec to process 10000
Output for 4.3.10
Switch: 0.008981 sec to process 10000 Map: 0.005262 sec to process 10000
Output for 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.007735 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.004734 sec to process 10000PHP_EOL
Output for 4.3.8
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.006651 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.004207 sec to process 10000PHP_EOL
Output for 4.3.7
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.009926 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.005660 sec to process 10000PHP_EOL
Output for 4.3.6
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.010677 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.005469 sec to process 10000PHP_EOL
Output for 4.3.5
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.009723 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.005703 sec to process 10000PHP_EOL
Output for 4.3.4
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.008487 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.004798 sec to process 10000PHP_EOL
Output for 4.3.3
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.009722 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.005461 sec to process 10000PHP_EOL
Output for 4.3.2
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.006130 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.003494 sec to process 10000PHP_EOL
Output for 4.3.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.008121 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.004732 sec to process 10000PHP_EOL
Output for 4.3.0
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 42 Switch: 0.005853 sec to process 10000PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/ipXlT on line 60 Map: 0.003440 sec to process 10000PHP_EOL