3v4l.org

run code in 300+ PHP versions simultaneously
<?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); for ($i = 0; $i < $iterations; ++$i) { $map = array( 'apple' => 'red', 'banana' => 'yellow', 'carrot' => 'orange', 'date' => 'brown', 'endive' => 'green' ); $color = $map[$samples[$i]]; } $end_map = microtime(TRUE); $total_map = $end_map - $start_map; printf("Map:\t%0.6f sec to process %d" . PHP_EOL, $total_map, $iterations);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.4.00.0120.00915.25
7.3.120.0130.00615.17
7.3.110.0080.01015.37
7.3.100.0070.01115.31
7.3.90.0000.01815.34
7.3.80.0080.00315.34
7.3.70.0030.01015.33
7.3.60.0000.01814.93
7.3.50.0100.01015.13
7.3.40.0060.00915.07
7.3.30.0040.00815.04
7.3.20.0080.00816.45
7.3.10.0100.00616.55
7.3.00.0020.01016.71
7.2.250.0030.01615.52
7.2.240.0060.01615.59
7.2.230.0070.01015.40
7.2.220.0070.01015.59
7.2.210.0000.01115.53
7.2.200.0000.01815.20
7.2.190.0130.00615.43
7.2.180.0070.01315.22
7.2.170.0000.01715.34
7.2.130.0100.00717.06
7.2.120.0100.00716.87
7.2.110.0000.01516.53
7.2.100.0080.00816.79
7.2.90.0120.00616.80
7.2.80.0100.01016.75
7.2.70.0060.01217.05
7.2.60.0150.01516.62
7.2.50.0170.00616.63
7.2.40.0040.01516.58
7.2.30.0070.01016.81
7.2.20.0030.01017.02
7.2.10.0080.01116.68
7.2.00.0110.00718.10
7.1.330.0090.00915.76
7.1.320.0070.01315.81
7.1.310.0070.01015.88
7.1.300.0100.00715.87
7.1.290.0070.01315.68
7.1.280.0030.01015.52
7.1.270.0060.01315.66
7.1.260.0070.01116.05
7.1.250.0030.01415.78
7.1.70.0000.01017.19
7.1.60.0060.02119.11
7.1.50.0110.01416.83
7.1.00.0070.07722.28
7.0.200.0030.00916.76
7.0.140.0070.07722.01
7.0.60.0300.06320.13
7.0.50.0030.08718.26
7.0.40.0130.07020.30
7.0.30.0170.04320.14
7.0.20.0230.09320.31
7.0.10.0070.09020.13
7.0.00.0070.09020.08
5.6.280.0070.08321.92
5.6.210.0100.09021.34
5.6.200.0100.06018.88
5.6.190.0100.05721.29
5.6.180.0300.04021.09
5.6.170.1100.05021.11
5.6.160.0130.09021.22
5.6.150.0070.06018.85
5.6.140.0070.06018.95
5.6.130.0170.08018.94
5.6.120.0030.09721.67
5.6.110.0200.08021.93
5.6.100.0070.10321.90
5.6.90.0130.07321.77
5.6.80.0000.05321.08
5.5.350.0170.08721.29
5.5.340.0100.07718.49
5.5.330.0000.07720.88
5.5.320.0430.07320.99
5.5.310.0200.05020.89
5.5.300.0000.04718.49
5.5.290.0100.04718.68
5.5.280.0070.09721.45
5.5.270.0100.05321.55
5.5.260.0100.06021.63
5.5.250.0100.09721.45
5.5.240.0200.08021.14
5.4.450.0730.07020.20
5.4.440.1170.05720.13
5.4.430.0930.07019.85
5.4.420.0900.00020.23
5.4.410.0870.00019.95
5.4.400.0730.00019.87
5.4.390.0730.00019.71
5.4.380.1000.00019.90
5.4.370.0730.00019.70
5.4.360.0730.00019.70
5.4.350.0800.00019.80
5.4.340.0030.04512.96
5.4.320.0080.04913.45
5.4.310.0060.04613.45
5.4.300.0060.04813.45
5.4.290.0050.04613.45
5.4.280.0050.04513.35
5.4.270.0060.05513.35
5.4.260.0070.05613.34
5.4.250.0090.05213.34
5.4.240.0090.04913.34
5.4.230.0080.05913.34
5.4.220.0080.04713.34
5.4.210.0100.05813.34
5.4.200.0120.04513.34
5.4.190.0060.07213.34
5.4.180.0060.04813.33
5.4.170.0080.04013.34
5.4.160.0050.04313.34
5.4.150.0100.04513.34
5.4.140.0090.05313.02
5.4.130.0060.04913.00
5.4.120.0080.04012.96
5.4.110.0080.04512.96
5.4.100.0050.04512.96
5.4.90.0070.04512.96
5.4.80.0060.04612.96
5.4.70.0030.04612.96
5.4.60.0070.04712.95
5.4.50.0060.04812.96
5.4.40.0100.04112.95
5.4.30.0060.05312.95
5.4.20.0070.04912.95
5.4.10.0070.04912.95
5.4.00.0050.04712.43
5.3.290.0090.04513.64
5.3.280.0080.04713.57
5.3.270.0070.05313.58
5.3.260.0070.05613.58
5.3.250.0100.04413.58
5.3.240.0110.05413.58
5.3.230.0070.04813.57
5.3.220.0030.05013.54
5.3.210.0060.04913.54
5.3.200.0080.05413.54
5.3.190.0090.05113.54
5.3.180.0070.05013.54
5.3.170.0070.05913.54
5.3.160.0080.04513.54
5.3.150.0090.04413.54
5.3.140.0100.04613.53
5.3.130.0030.05713.52
5.3.120.0090.05713.52
5.3.110.0060.05213.52
5.3.100.0050.04813.01
5.3.90.0080.04713.00
5.3.80.0050.04812.99
5.3.70.0040.04713.00
5.3.60.0070.05112.97
5.3.50.0080.05012.92
5.3.40.0080.04512.91
5.3.30.0070.04312.88
5.3.20.0060.05212.66
5.3.10.0080.04712.63
5.3.00.0070.04612.61
5.2.170.0050.05010.12
5.2.160.0070.04910.12
5.2.150.0080.06310.12
5.2.140.0060.05210.12
5.2.130.0050.04710.07
5.2.120.0040.05510.07
5.2.110.0050.04210.07
5.2.100.0060.04010.07
5.2.90.0060.04010.07
5.2.80.0050.04310.06
5.2.70.0080.04010.06
5.2.60.0050.04110.08
5.2.50.0060.0529.99
5.2.40.0060.0489.96
5.2.30.0100.0429.75
5.2.20.0060.0399.74
5.2.10.0060.0429.66
5.2.00.0050.0409.54
5.1.60.0050.0359.14
5.1.50.0040.0389.14
5.1.40.0050.0359.13
5.1.30.0050.0399.47
5.1.20.0070.0389.50
5.1.10.0140.0579.29
5.1.00.0030.0409.29
5.0.50.0040.0417.71
5.0.40.0050.0437.56
5.0.30.0060.0567.38
5.0.20.0050.0417.34
5.0.10.0050.0407.32
5.0.00.0030.0557.32
4.4.90.0020.0385.73
4.4.80.0020.0385.70
4.4.70.0070.0355.70
4.4.60.0040.0505.70
4.4.50.0060.0365.72
4.4.40.0040.0695.71
4.4.30.0050.0405.71
4.4.20.0030.0365.77
4.4.10.0030.0405.78
4.4.00.0050.0475.74
4.3.110.0040.0405.64
4.3.100.0060.0365.64
4.3.90.0020.0365.66
4.3.80.0030.0465.66
4.3.70.0050.0355.65
4.3.60.0070.0455.66
4.3.50.0030.0385.65
4.3.40.0040.0455.61
4.3.30.0040.0364.43
4.3.20.0020.0484.41
4.3.10.0030.0484.35
4.3.00.0130.0737.25

preferences:
30.76 ms | 401 KiB | 5 Q