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 = 1000000; 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.0030.17316.63
7.3.00.0070.14216.58
7.2.130.0030.20217.00
7.2.120.0130.20217.04
7.2.110.0070.18216.92
7.2.100.0030.19416.77
7.2.90.0030.19617.04
7.2.80.0160.19417.01
7.2.70.0100.18617.04
7.2.60.0070.19317.05
7.2.50.0100.21316.98
7.2.40.0100.18317.05
7.2.30.0000.19716.95
7.2.20.0100.20017.08
7.2.10.0030.19816.82
7.2.00.0020.16018.22
7.1.250.0000.35015.48
7.1.70.0130.15817.21
7.1.60.0130.21819.32
7.1.50.0100.20717.00
7.1.00.0000.18022.36
7.0.200.0200.14315.79
7.0.140.0030.27722.14
7.0.60.0070.23720.96
7.0.50.0000.23719.03
7.0.40.0030.24320.29
7.0.30.0270.22020.24
7.0.20.0270.26720.23
7.0.10.0270.19320.34
7.0.00.0100.17320.21
5.6.280.0100.38322.08
5.6.210.0070.34321.57
5.6.200.0030.37319.14
5.6.190.0100.36721.53
5.6.180.0400.36721.53
5.6.170.0300.37021.48
5.6.160.0200.39721.52
5.6.150.0070.32019.14
5.6.140.0070.35019.20
5.6.130.0070.34319.15
5.6.120.0070.34721.99
5.6.110.0100.32021.90
5.6.100.0130.37321.99
5.6.90.0030.37322.00
5.6.80.0030.37721.51
5.6.70.0330.36321.48
5.5.350.0030.37021.49
5.5.340.0000.33318.92
5.5.330.0130.36321.14
5.5.320.0270.34321.32
5.5.310.0270.40021.26
5.5.300.0000.33718.99
5.5.290.0030.41319.04
5.5.280.0070.32021.77
5.5.270.0070.32321.70
5.5.260.0070.38321.84
5.5.250.0030.36021.52
5.5.240.0100.37321.32
5.4.450.0030.44020.44
5.4.440.0030.38720.38
5.4.430.0130.36320.53
5.4.420.0130.35720.27
5.4.410.0130.37720.25
5.4.400.0500.34320.03
5.4.390.0100.31719.91
5.4.380.0100.36720.29
5.4.370.0130.37720.28
5.4.360.0100.32019.96
5.4.350.0200.36020.18
5.4.340.0200.29020.21
5.4.320.0070.32019.96
5.4.310.0600.29319.83
5.4.300.0070.30320.18
5.4.290.0070.34020.20
5.4.280.0070.37719.82
5.4.270.0100.38020.12
5.4.260.0130.36020.20
5.4.250.0100.37320.11
5.4.240.0030.38720.20
5.4.230.0130.36319.95
5.4.220.0100.43320.15
5.4.210.0170.36720.11
5.4.200.0070.37319.83
5.4.190.0130.38720.10
5.4.180.0570.36020.12
5.4.170.0070.38020.27
5.4.160.0100.37320.17
5.4.150.0170.38320.26
5.4.140.0070.32017.43
5.4.130.0100.32717.50
5.4.120.0170.36717.38
5.4.110.0070.38017.53
5.4.100.0170.36717.22
5.4.90.0070.36017.38
5.4.80.0100.32717.46
5.4.70.0070.37317.56
5.4.60.0170.35717.32
5.4.50.0130.33716.95
5.4.40.0030.35017.21
5.4.30.0030.38018.19
5.4.20.0070.38717.27
5.4.10.0170.37317.20
5.4.00.0100.40718.03
5.3.290.0200.33715.84
5.3.280.0070.45015.77
5.3.270.0070.39315.73
5.3.260.0130.38015.61
5.3.250.0170.37315.68
5.3.240.0100.33715.62
5.3.230.0170.36015.60
5.3.220.0130.33315.79
5.3.210.0200.40715.64
5.3.200.0130.40015.89
5.3.190.0100.40015.64
5.3.180.0130.39715.75
5.3.170.0100.42315.59
5.3.160.0100.38315.58
5.3.150.0070.40015.71
5.3.140.0100.35015.57
5.3.130.0170.39715.55
5.3.120.0170.38715.63
5.3.110.0430.36715.73
5.3.100.0000.33715.04
5.3.90.0100.38715.04
5.3.80.0070.41315.02
5.3.70.0130.42015.20
5.3.60.0100.40015.18
5.3.50.0430.39015.13
5.3.40.0130.43714.98
5.3.30.0070.36015.02
5.3.20.0100.40014.91
5.3.10.0200.42714.66
5.3.00.0130.40314.66
5.2.170.0100.48712.76
5.2.160.0100.46712.76
5.2.150.0100.49312.76
5.2.140.0100.45312.76
5.2.130.0100.47712.76
5.2.120.0100.48312.76
5.2.110.0100.48312.76
5.2.100.0030.47312.76
5.2.90.0100.45312.76
5.2.80.0070.48312.76
5.2.70.0070.48312.76
5.2.60.0070.48012.76
5.2.50.0100.43312.76
5.2.40.0000.49712.76
5.2.30.0030.46712.76
5.2.20.0000.45012.76
5.2.10.0030.48312.76
5.2.00.0030.53312.76
5.1.60.0100.60312.76
5.1.50.0070.66712.76
5.1.40.0070.53712.76
5.1.30.0100.50712.76
5.1.20.0130.50312.76
5.1.10.0030.55012.76
5.1.00.0130.49012.76
5.0.50.0030.94312.76
5.0.40.0030.96712.76
5.0.30.0000.96312.76
5.0.20.0031.05712.76
5.0.10.0000.93712.76
5.0.00.0001.02312.76
4.4.90.0030.99312.76
4.4.80.0000.97712.76
4.4.70.0000.96012.76
4.4.60.0071.03012.76
4.4.50.0031.00012.76
4.4.40.0030.99712.76
4.4.30.0000.99312.76
4.4.20.0000.94012.76
4.4.10.0000.92012.76
4.4.00.0100.93312.76
4.3.110.0070.93012.76
4.3.100.0001.05312.76
4.3.90.0000.98712.76
4.3.80.0001.00312.76
4.3.70.0000.94712.76
4.3.60.0001.00012.76
4.3.50.0000.97712.76
4.3.40.0071.02012.76
4.3.30.1001.03712.76
4.3.20.0031.04312.76
4.3.10.0030.91012.76
4.3.00.0071.01312.76

preferences:
37.39 ms | 401 KiB | 5 Q