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); $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);

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)
8.1.120.0100.00519.01
8.1.110.0070.00320.53
8.1.100.0000.01518.99
8.1.90.0130.00219.00
8.1.80.0060.01118.96
8.1.70.0060.00618.98
8.1.60.0090.00619.07
8.1.50.0100.00719.02
8.1.40.0150.00219.08
8.1.30.0110.00819.20
8.1.20.0140.00519.17
8.1.10.0130.00919.04
8.1.00.0160.00319.14
8.0.250.0050.00818.21
8.0.240.0160.00018.37
8.0.230.0120.00418.20
8.0.220.0100.00618.29
8.0.210.0090.00618.26
8.0.200.0000.01618.36
8.0.190.0120.00418.34
8.0.180.0150.00018.38
8.0.170.0160.00018.31
8.0.160.0080.00818.29
8.0.150.0130.00318.35
8.0.140.0100.00718.20
8.0.130.0050.00518.27
8.0.120.0090.00518.09
8.0.110.0110.00318.29
8.0.100.0060.00918.19
8.0.90.0110.00618.21
8.0.80.0120.00418.30
8.0.70.0100.00618.29
8.0.60.0160.00018.20
8.0.50.0100.00718.16
8.0.30.0160.00018.17
8.0.20.0000.01518.32
8.0.10.0130.00318.48
8.0.00.0120.00019.91
7.4.330.0060.00014.74
7.4.320.0050.01017.95
7.4.300.0120.00417.83
7.4.290.0100.00718.07
7.4.280.0110.00717.84
7.4.270.0140.00217.83
7.4.260.0090.00217.95
7.4.250.0000.01517.83
7.4.240.0160.00017.86
7.4.230.0170.00017.88
7.4.220.0090.00517.93
7.4.210.0070.00718.01
7.4.200.0130.00318.01
7.4.190.0120.00317.98
7.4.180.0090.00617.97
7.4.160.0120.00317.92
7.4.150.0000.01517.83
7.4.140.0080.00617.93
7.4.130.0080.00617.65
7.4.120.0090.00318.18
7.4.110.0070.00717.84
7.4.100.0110.00317.95
7.4.90.0100.00217.79
7.4.80.0000.01317.97
7.4.70.0070.00718.02
7.4.60.0120.00317.98
7.4.50.0090.00317.75
7.4.40.0070.00717.81
7.4.30.0070.00718.00
7.4.20.0090.00417.87
7.4.10.0030.00817.82
7.4.00.0050.00717.87
7.3.330.0050.01017.68
7.3.320.0080.00817.71
7.3.310.0100.00517.64
7.3.300.0120.00317.61
7.3.290.0070.00717.70
7.3.280.0050.01017.60
7.3.270.0090.00617.71
7.3.260.0090.00617.62
7.3.250.0110.00417.60
7.3.240.0090.00617.72
7.3.230.0050.01017.58
7.3.220.0110.00417.77
7.3.210.0150.00017.72
7.3.200.0040.01117.60
7.3.190.0090.00917.68
7.3.180.0120.00417.68
7.3.170.0000.01517.83
7.3.160.0120.00317.82
7.3.150.0050.01017.66
7.3.140.0150.00017.58
7.3.130.0110.00417.61
7.3.120.0110.00517.68
7.3.110.0110.00417.52
7.3.100.0050.01017.53
7.3.90.0080.00817.79
7.3.80.0110.00517.48
7.3.70.0110.00617.69
7.3.60.0080.00817.87
7.3.50.0120.00617.91
7.3.40.0130.00217.77
7.3.30.0110.00418.02
7.3.20.0100.00519.34
7.3.10.0050.01119.27
7.3.00.0050.01119.36
7.2.340.0040.00719.16
7.2.330.0110.00517.93
7.2.320.0080.00817.96
7.2.310.0090.00717.98
7.2.300.0130.00417.74
7.2.290.0100.00517.74
7.2.280.0110.00417.91
7.2.270.0110.00417.98
7.2.260.0030.01217.73
7.2.250.0130.00317.95
7.2.240.0150.00317.93
7.2.230.0110.00517.88
7.2.220.0120.00317.93
7.2.210.0080.00817.75
7.2.200.0160.00018.06
7.2.190.0060.00918.11
7.2.180.0120.00417.96
7.2.170.0100.00518.17
7.2.160.0070.00718.22
7.2.150.0110.00719.54
7.2.140.0150.00019.57
7.2.130.0060.00919.59
7.2.120.0120.00319.56
7.2.110.0150.00019.59
7.2.100.0000.01519.71
7.2.90.0120.00419.52
7.2.80.0080.00819.69
7.2.70.0090.00619.69
7.2.60.0120.00719.47
7.2.50.0130.00319.69
7.2.40.0080.00819.50
7.2.30.0120.00319.69
7.2.20.0160.00019.75
7.2.10.0070.00719.76
7.2.00.0090.01019.49
7.1.330.0060.00918.39
7.1.320.0120.00318.32
7.1.310.0070.00718.40
7.1.300.0140.00018.54
7.1.290.0050.01018.57
7.1.280.0150.00018.21
7.1.270.0070.00718.28
7.1.260.0130.00218.51
7.1.250.0100.00518.33
7.1.240.0110.00318.38
7.1.230.0050.01018.43
7.1.220.0090.00618.26
7.1.210.0090.00618.39
7.1.200.0110.00418.30
7.1.190.0090.00618.53
7.1.180.0090.00618.47
7.1.170.0120.00418.25
7.1.160.0100.00518.24
7.1.150.0120.00418.33
7.1.140.0150.00018.33
7.1.130.0080.00818.45
7.1.120.0100.00518.46
7.1.110.0100.00518.24
7.1.100.0070.00718.34
7.1.90.0080.00818.48
7.1.80.0070.00718.27
7.1.70.0060.00817.65
7.1.60.0100.01118.80
7.1.50.0130.00817.73
7.1.40.0100.00518.36
7.1.30.0130.00218.50
7.1.20.0100.00518.53
7.1.10.0100.00518.33
7.1.00.0120.03320.36
7.0.330.0120.00218.00
7.0.320.0090.00717.96
7.0.310.0000.01517.97
7.0.300.0080.00818.18
7.0.290.0070.00718.18
7.0.280.0050.01017.97
7.0.270.0070.00717.95
7.0.260.0110.00418.08
7.0.250.0100.00518.25
7.0.240.0120.00418.27
7.0.230.0120.00218.23
7.0.220.0070.00718.03
7.0.210.0090.00518.15
7.0.200.0070.00717.46
7.0.190.0070.00718.02
7.0.180.0090.00617.95
7.0.170.0050.01018.30
7.0.160.0090.00618.02
7.0.150.0090.00618.01
7.0.140.0060.04420.21
7.0.130.0120.00218.16
7.0.120.0140.00018.16
7.0.110.0120.00318.20
7.0.100.0000.01518.13
7.0.90.0070.00718.08
7.0.80.0120.00317.98
7.0.70.2400.02219.16
7.0.60.0100.04019.28
7.0.50.0050.02918.05
7.0.40.0100.03019.15
7.0.30.0270.04219.05
7.0.20.0160.04819.19
7.0.10.0190.02819.17
7.0.00.0060.04019.18
5.6.400.0110.00617.86
5.6.390.0150.00317.64
5.6.380.0110.00617.73
5.6.370.0180.00017.90
5.6.360.0140.00317.75
5.6.350.0060.01117.88
5.6.340.0130.00417.89
5.6.330.0090.00917.65
5.6.320.0090.00917.78
5.6.310.0090.00917.86
5.6.300.0050.01117.46
5.6.290.0050.01117.77
5.6.280.0040.01317.73
5.6.270.0140.00317.83
5.6.260.0080.00817.83
5.6.250.0110.00617.74
5.6.240.0040.01317.96
5.6.230.0100.00718.14
5.6.220.0090.00917.96
5.6.210.0120.04219.77
5.6.200.0120.04018.45
5.6.190.0070.03219.54
5.6.180.0110.04519.61
5.6.170.0160.02619.55
5.6.160.0150.04319.66
5.6.150.0070.03518.43
5.6.140.0120.04218.51
5.6.130.0120.03818.38
5.6.120.0080.03119.85
5.6.110.0100.02219.79
5.6.100.0100.04019.99
5.6.90.0050.04719.92
5.6.80.0100.02119.58
5.6.70.0220.03519.59
5.6.60.0110.00518.00
5.6.50.0060.01117.73
5.6.40.0040.01217.83
5.6.30.0110.00617.82
5.6.20.0090.00917.96
5.6.10.0050.01117.97
5.6.00.0110.00518.02
5.5.380.0080.00818.10
5.5.370.0080.00818.01
5.5.360.0110.00617.75
5.5.350.0060.02619.52
5.5.340.0170.03818.23
5.5.330.0030.05219.53
5.5.320.0100.03219.43
5.5.310.0190.02919.32
5.5.300.0120.04318.25
5.5.290.0090.02818.34
5.5.280.0040.05219.81
5.5.270.0080.03319.60
5.5.260.0120.04319.60
5.5.250.0060.04619.68
5.5.240.0100.03819.44
5.5.230.0110.00617.96
5.5.220.0140.00317.96
5.5.210.0140.00318.06
5.5.200.0130.00317.90
5.5.190.0100.00717.64
5.5.180.0080.00817.66
5.5.170.0080.00817.66
5.5.160.0140.00317.80
5.5.150.0110.00617.73
5.5.140.0120.00617.63
5.5.130.0120.00617.54
5.5.120.0080.00817.54
5.5.110.0000.01717.54
5.5.100.0110.00517.76
5.5.90.0100.00817.88
5.5.80.0120.00617.81
5.5.70.0050.01117.77
5.5.60.0080.00817.93
5.5.50.0090.00617.95
5.5.40.0060.01117.96
5.5.30.0080.00817.75
5.5.20.0100.00618.01
5.5.10.0040.01317.89
5.5.00.0130.00517.92
5.4.450.0130.04517.08
5.4.440.0150.03017.12
5.4.430.0200.04017.14
5.4.420.0210.04016.93
5.4.410.0200.04016.86
5.4.400.0170.03416.97
5.4.390.0160.04616.94
5.4.380.0170.03216.87
5.4.370.0230.03816.97
5.4.360.0190.02916.98
5.4.350.0150.04016.90
5.4.340.0210.03316.85
5.4.330.0060.00913.98
5.4.320.0160.03316.89
5.4.310.0170.03416.92
5.4.300.0210.04016.75
5.4.290.0130.04416.88
5.4.280.0170.03416.98
5.4.270.0200.03916.87
5.4.260.0190.04216.87
5.4.250.0140.04516.92
5.4.240.0120.04616.76
5.4.230.0170.03216.79
5.4.220.0170.03816.88
5.4.210.0150.02916.88
5.4.200.0240.03716.86
5.4.190.0190.03516.87
5.4.180.0160.03016.97
5.4.170.0100.04916.88
5.4.160.0160.04116.97
5.4.150.0160.04616.75
5.4.140.0190.03215.53
5.4.130.0160.04115.52
5.4.120.0150.04415.65
5.4.110.0170.04015.53
5.4.100.0150.02615.59
5.4.90.0150.04315.54
5.4.80.0160.03115.47
5.4.70.0170.04215.53
5.4.60.0170.03615.47
5.4.50.0180.03115.53
5.4.40.0160.03315.55
5.4.30.0120.02415.59
5.4.20.0150.03315.58
5.4.10.0180.02015.60
5.4.00.0170.02715.18
5.3.290.0160.04414.70
5.3.280.0160.04114.65
5.3.270.0160.03714.62
5.3.260.0140.04814.67
5.3.250.0160.04214.59
5.3.240.0180.04314.60
5.3.230.0210.03914.62
5.3.220.0220.04014.60
5.3.210.0160.04814.60
5.3.200.0170.04414.72
5.3.190.0270.02814.61
5.3.180.0230.02514.59
5.3.170.0150.03014.60
5.3.160.0180.04414.64
5.3.150.0180.03014.59
5.3.140.0170.04214.71
5.3.130.0180.04214.64
5.3.120.0180.04214.60
5.3.110.0200.03314.64
5.3.100.0200.03914.44
5.3.90.0160.04414.38
5.3.80.0220.02614.31
5.3.70.0200.03914.37
5.3.60.0100.04214.35
5.3.50.0160.03814.26
5.3.40.0200.04014.29
5.3.30.0190.02814.26
5.3.20.0210.03114.21
5.3.10.0130.04314.19
5.3.00.0210.03114.18

preferences:
49.59 ms | 401 KiB | 5 Q