3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_1($nb) { $t = microtime(true); $a = 'f'; $t = microtime(true); $b = ''; $t = microtime(true); for ($u=0; $u<$nb; $u++) { if ($a==='a') { $b .= $a; } else if ($a==='b') { $b .= $a; } else if ($a==='c') { $b .= $a; } else if ($a==='d') { $b .= $a; } else if ($a==='e') { $b .= $a; } else if ($a==='f') { $b .= $a; } } return (microtime(true) - $t); } function test_2($nb) { $a = 'f'; $b = ''; $t = microtime(true); for ($u=0; $u<$nb; $u++) { switch ($a) { case 'a': $b .= $a; case 'b': $b .= $a; case 'c': $b .= $a; case 'd': $b .= $a; case 'e': $b .= $a; case 'f': $b .= $a; } } return (microtime(true) - $t); } $nb = 100000; echo 'test_1: '.test_1($nb)."\n"; echo 'test_2: '.test_2($nb)."\n";

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.3.10.0040.02816.38
7.3.00.0030.02316.69
7.2.130.0120.01816.91
7.2.120.0150.01816.80
7.2.110.0030.02817.08
7.2.100.0030.03816.89
7.2.90.0120.02116.89
7.2.80.0030.02616.74
7.2.70.0040.02816.92
7.2.60.0100.02316.88
7.2.50.0030.02717.00
7.2.40.0030.03217.05
7.2.30.0000.02916.97
7.2.20.0030.02616.95
7.2.10.0100.02517.05
7.2.00.0100.02318.03
7.1.250.0100.03915.84
7.1.70.0070.03817.29
7.1.60.0060.04519.32
7.1.50.0130.03916.99
7.1.00.0000.05022.36
7.0.200.0000.02516.82
7.0.140.0070.10022.18
7.0.110.0530.07020.24
7.0.100.0600.09020.21
7.0.90.0530.11020.11
7.0.80.0570.10720.00
7.0.70.0670.10020.21
7.0.60.0630.09720.10
7.0.50.0630.07720.59
7.0.40.0030.10720.16
7.0.30.0100.10320.24
7.0.20.0070.09720.18
7.0.10.0070.10320.27
7.0.00.0230.09320.03
5.6.280.0030.12021.00
5.6.250.0100.11320.70
5.6.240.0170.10020.68
5.6.230.0030.13020.65
5.6.220.0070.10320.95
5.6.210.0070.11320.76
5.6.200.0030.09721.40
5.6.190.0030.11721.39
5.6.180.0200.11021.38
5.6.170.0130.10321.16
5.6.160.0100.11721.30
5.6.150.0000.09321.19
5.6.140.0170.11021.09
5.6.130.0100.11021.04
5.6.120.0030.12321.22
5.6.110.0200.10321.08
5.6.100.0100.11021.18
5.6.90.0170.12320.99
5.6.80.0100.11320.48
5.6.70.0070.12020.54
5.6.60.0130.12020.55
5.6.50.0170.11020.48
5.6.40.0130.09320.58
5.6.30.0070.10720.43
5.6.20.0130.11320.58
5.6.10.0170.08020.39
5.6.00.0030.11320.59
5.5.380.0100.10320.57
5.5.370.0130.11720.64
5.5.360.0100.12020.56
5.5.350.0070.11320.58
5.5.340.0000.12321.06
5.5.330.0100.12321.12
5.5.320.0200.10321.01
5.5.310.0130.11721.10
5.5.300.0100.12020.95
5.5.290.0130.10020.95
5.5.280.0130.11321.12
5.5.270.0130.12021.09
5.5.260.0130.10020.99
5.5.250.0070.12020.70
5.5.240.0100.11720.36
5.5.230.0070.11720.30
5.5.220.0130.11320.39
5.5.210.0100.08020.48
5.5.200.0070.11020.31
5.5.190.0030.13020.43
5.5.180.0070.11720.30
5.5.160.0030.12720.30
5.5.150.0100.11320.48
5.5.140.0130.11020.41
5.5.130.0130.09320.43
5.5.120.0100.08320.49
5.5.110.0130.12020.32
5.5.100.0030.12020.20
5.5.90.0100.12020.27
5.5.80.0070.11320.33
5.5.70.0100.11020.14
5.5.60.0100.11320.34
5.5.50.0070.12720.11
5.5.40.0100.11320.14
5.5.30.0100.11720.36
5.5.20.0070.12020.13
5.5.10.0100.10320.04
5.5.00.0130.10720.00
5.4.450.0100.10719.44
5.4.440.0100.12319.38
5.4.430.0100.08319.50
5.4.420.0130.11019.58
5.4.410.0070.10719.34
5.4.400.0070.12019.11
5.4.390.0100.11719.28
5.4.380.0170.10719.26
5.4.370.0030.11319.09
5.4.360.0070.12319.41
5.4.350.0030.11719.05
5.4.340.0100.12319.10
5.4.320.0070.12019.41
5.4.310.0100.11719.28
5.4.300.0000.12319.29
5.4.290.0070.08319.10
5.4.280.0100.11719.33
5.4.270.0030.11019.14
5.4.260.0070.12019.08
5.4.250.0100.11019.32
5.4.240.0170.10319.12
5.4.230.0100.10019.08
5.4.220.0070.08319.09
5.4.210.0070.11719.25
5.4.200.0130.07719.10
5.4.190.0030.10719.27
5.4.180.0030.08319.12
5.4.170.0070.10719.11
5.4.160.0070.11719.09
5.4.150.0200.10319.26
5.4.140.0030.11316.46
5.4.130.0100.10716.74
5.4.120.0130.09716.54
5.4.110.0100.11016.71
5.4.100.0030.11016.70
5.4.90.0130.11716.59
5.4.80.0070.11016.55
5.4.70.0070.11316.69
5.4.60.0100.10716.64
5.4.50.0100.11716.48
5.4.40.0030.08316.63
5.4.30.0200.09716.36
5.4.20.0070.08716.44
5.4.10.0100.10716.43
5.4.00.0030.12315.85
5.3.290.0070.12014.86
5.3.280.0130.11714.66
5.3.270.0100.11314.71
5.3.260.0170.10314.75
5.3.250.0100.09014.84
5.3.240.0100.10714.75
5.3.230.0170.10014.56
5.3.220.0100.11714.80
5.3.210.0130.11714.69
5.3.200.0070.11714.75
5.3.190.0100.11014.53
5.3.180.0070.08714.64
5.3.170.0070.11014.89
5.3.160.0100.09014.69
5.3.150.0100.12714.66
5.3.140.0100.11014.74
5.3.130.0130.12014.78
5.3.120.0130.11314.79
5.3.110.0100.13014.74
5.3.100.0030.11314.14
5.3.90.0100.11014.34
5.3.80.0030.11714.26
5.3.70.0030.12314.15
5.3.60.0100.11314.09
5.3.50.0070.12714.11
5.3.40.0070.08314.28
5.3.30.0030.11014.03
5.3.20.0070.12313.81
5.3.10.0130.10713.82
5.3.00.0100.11013.71
5.2.170.0030.11711.24
5.2.160.0200.11311.25
5.2.150.0100.11311.25
5.2.140.0030.11311.47
5.2.130.0070.08711.34
5.2.120.0170.07011.23
5.2.110.0070.09711.22
5.2.100.0070.09011.21
5.2.90.0000.10311.17
5.2.80.0070.09011.22
5.2.70.0030.12311.29
5.2.60.0100.07711.12
5.2.50.0000.11711.19
5.2.40.0030.13011.23
5.2.30.0030.10711.09
5.2.20.0030.08710.91
5.2.10.0070.11311.10
5.2.00.0030.12310.79
5.1.60.0000.12010.36
5.1.50.0100.12710.36
5.1.40.0070.12710.27
5.1.30.0030.11010.59
5.1.20.0030.13010.49
5.1.10.0030.09310.27
5.1.00.0000.14310.27
5.0.50.0330.16010.27
5.0.40.0000.17310.27
5.0.30.0070.17710.27
5.0.20.0030.17010.27
5.0.10.0000.17010.27
5.0.00.0030.17710.27
4.4.90.0000.16710.27
4.4.80.0000.16710.27
4.4.70.0030.16310.27
4.4.60.0030.11710.27
4.4.50.0030.14710.27
4.4.40.0030.15010.27
4.4.30.0100.17710.27
4.4.20.0070.16710.27
4.4.10.0000.18010.27
4.4.00.0030.18710.27
4.3.110.0000.15710.27
4.3.100.0070.17310.27
4.3.90.0000.16310.27
4.3.80.0000.19710.27
4.3.70.0070.18710.27
4.3.60.0030.17710.27
4.3.50.0030.14710.27
4.3.40.0030.17310.27
4.3.30.0030.16710.27
4.3.20.0030.17710.27
4.3.10.0030.14010.27
4.3.00.0030.13310.27

preferences:
37.06 ms | 401 KiB | 5 Q