3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('test1', 'test2', 'test3', 'test4'); $var = 'test'; $iterations = 1000000; $start = microtime(true); for($i = 0; $i < $iterations; ++$i) { if ($var != 'test1' && $var != 'test2' && $var != 'test3' && $var != 'test4') {} } $end = microtime(true); print "multiple comparisons: \n". ($end - $start)."\n"; $start2 = microtime(true); for($i = 0; $i < $iterations; ++$i) { if (!in_array($var, $array) ) {} } $end2 = microtime(true); print "in_array: \n".($end2 - $start2)."\n"; $start = microtime(true); $array_flip = array_flip($array); for($i = 0; $i < $iterations; ++$i) { if (!isset($array_flip[$var])) {} } $end = microtime(true); print "array_flip() outside loop measured + isset(): \n".($end - $start)."\n"; $array_flip = array_flip($array); $start = microtime(true); for($i = 0; $i < $iterations; ++$i) { if (!isset($array_flip[$var])) {} } $end = microtime(true); print "array_flip() outside loop not measured + isset(): \n".($end - $start)."\n"; $start = microtime(true); for($i = 0; $i < $iterations; ++$i) { foreach ($array as $entry) { if ($entry == $var) {} } } $end = microtime(true); print "foreach and compoarison: \n".($end - $start)."\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)
8.2.110.0100.12420.88
8.2.100.0100.12219.17
8.2.90.0150.11918.78
8.2.80.0080.12918.72
8.2.70.0230.10918.79
8.2.60.0130.10618.81
8.2.50.0170.11718.72
8.2.40.0100.10618.76
8.2.30.0170.12618.71
8.2.20.0070.10618.82
8.2.10.0070.12318.92
8.2.00.0130.10618.96
8.1.240.0170.14618.52
8.1.230.0160.10818.48
8.1.220.0130.11218.63
8.1.210.0050.11119.92
8.1.200.0120.12318.35
8.1.190.0150.12118.39
8.1.180.0110.10718.39
8.1.170.0170.11618.47
8.1.160.0080.11618.87
8.1.150.0140.12720.49
8.1.140.0130.13518.50
8.1.130.0160.09818.54
8.1.120.0120.12818.63
8.1.110.0130.11118.57
8.1.100.0160.10918.45
8.1.90.0070.13618.59
8.1.80.0120.10818.60
8.1.70.0090.12618.38
8.1.60.0110.11218.32
8.1.50.0180.12218.25
8.1.40.0110.11618.24
8.1.30.0100.11718.47
8.1.20.0120.14218.06
8.1.10.0090.12118.37
8.1.00.0140.11818.37
8.0.300.0120.11717.88
8.0.290.0150.13117.85
8.0.280.0170.11917.73
8.0.270.0070.11117.84
8.0.260.0150.13217.82
8.0.250.0080.11217.88
8.0.240.0120.12217.81
8.0.230.0160.12518.28
8.0.220.0130.12517.68
8.0.210.0160.12017.81
8.0.200.0150.12817.36
8.0.190.0110.12717.57
8.0.180.0120.11217.52
8.0.170.0110.12117.54
8.0.160.0110.12417.54
8.0.150.0170.12417.50
8.0.140.0100.12917.41
8.0.130.0120.13317.56
8.0.120.0170.13317.31
8.0.110.0120.13817.38
8.0.100.0160.13917.28
8.0.90.0130.12717.31
8.0.80.0140.13017.32
8.0.70.0120.14017.23
8.0.60.0120.13117.21
8.0.50.0080.14317.31
8.0.30.0110.16917.20
8.0.20.0160.16417.31
8.0.10.0100.20217.32
8.0.00.0100.17518.53
7.4.330.0100.12916.25
7.4.320.0070.10817.47
7.4.300.0130.13117.15
7.4.290.0100.12317.12
7.4.280.0100.14117.12
7.4.270.0080.12317.16
7.4.260.0050.16616.92
7.4.250.0090.14417.02
7.4.240.0070.15116.83
7.4.230.0100.14517.00
7.4.220.0070.15116.84
7.4.210.0120.14716.96
7.4.200.0100.13917.01
7.4.190.0160.15017.03
7.4.180.0090.15017.10
7.4.160.0090.18016.98
7.4.150.0070.17216.93
7.4.140.0110.18116.74
7.4.130.0100.18016.79
7.4.120.0150.19616.58
7.4.110.0120.19516.65
7.4.100.0140.20216.79
7.4.90.0130.21116.61
7.4.80.0120.21316.63
7.4.70.0120.21216.65
7.4.60.0120.21916.66
7.4.50.0130.20216.66
7.4.40.0120.20716.56
7.4.30.0120.21216.61
7.4.20.0130.21316.72
7.4.10.0110.19516.62
7.4.00.0090.20316.66
7.3.330.0090.18216.67
7.3.320.0140.18616.72
7.3.310.0120.18316.66
7.3.300.0140.17916.73
7.3.290.0150.17016.81
7.3.280.0150.17216.77
7.3.270.0160.20116.62
7.3.260.0160.21916.56
7.3.250.0140.21516.71
7.3.240.0130.23516.44
7.3.230.0140.22016.49
7.3.220.0160.22816.49
7.3.210.0140.26016.51
7.3.200.0140.26116.52
7.3.190.0090.25516.40
7.3.180.0110.24716.46
7.3.170.0110.24416.46
7.3.160.0110.24116.52
7.3.150.0120.24816.59
7.3.140.0110.23816.53
7.3.130.0130.24616.47
7.3.120.0150.24616.35
7.3.110.0130.24116.43
7.3.100.0120.26616.41
7.3.90.0090.25616.60
7.3.80.0140.28116.54
7.3.70.0110.27916.57
7.3.60.0110.25216.54
7.3.50.0120.25116.55
7.3.40.0120.25116.61
7.3.30.0080.23516.23
7.3.20.0220.23316.68
7.3.10.0210.23416.66
7.3.00.0210.23816.72
7.2.340.0140.23516.59
7.2.330.0150.24016.72
7.2.320.0150.24716.71
7.2.310.0140.23616.63
7.2.300.0150.23416.68
7.2.290.0160.22416.69
7.2.280.0120.22416.74
7.2.270.0170.22616.70
7.2.260.0160.22416.73
7.2.250.0160.25916.66
7.2.240.0140.23816.69
7.2.230.0110.26116.71
7.2.220.0170.23816.79
7.2.210.0120.24116.72
7.2.200.0160.24316.81
7.2.190.0150.23116.73
7.2.180.0140.23016.74
7.2.170.0130.23216.86
7.2.160.0130.24716.42
7.2.150.0240.23517.14
7.2.140.0220.22417.10
7.2.130.0230.21117.19
7.2.120.0220.21817.16
7.2.110.0240.22017.20
7.2.100.0240.22917.20
7.2.90.0270.23317.20
7.2.80.0220.22117.17
7.2.70.0220.22117.15
7.2.60.0250.21317.17
7.2.50.0330.23317.14
7.2.40.0260.23317.17
7.2.30.0260.23117.15
7.2.20.0250.24817.15
7.2.10.0200.22717.38
7.2.00.0290.23217.16
7.1.330.0180.27616.53
7.1.320.0200.26816.48
7.1.310.0180.28316.56
7.1.300.0180.29216.49
7.1.290.0150.27516.51
7.1.280.0190.27316.57
7.1.270.0280.25716.01
7.1.260.0260.24616.02
7.1.250.0250.25016.02
7.1.240.0260.27516.21
7.1.230.0240.25716.27
7.1.220.0270.30116.25
7.1.210.0230.28616.22
7.1.200.0260.26716.17
7.1.190.0230.26716.23
7.1.180.0250.27316.16
7.1.170.0250.27516.40
7.1.160.0230.28016.23
7.1.150.0200.26716.21
7.1.140.0220.25816.18
7.1.130.0220.26016.18
7.1.120.0210.26016.20
7.1.110.0210.27316.21
7.1.100.0250.30216.21
7.1.90.0250.27416.16
7.1.80.0210.27416.27
7.1.70.0250.26016.16
7.1.60.0210.26616.22
7.1.50.0250.25716.25
7.1.40.0220.27816.29
7.1.30.0310.27016.29
7.1.20.0200.26216.18
7.1.10.0190.26116.26
7.1.00.0160.28016.22
7.0.330.0150.15617.95
7.0.320.0130.15417.74
7.0.310.0190.16117.84
7.0.300.0150.17517.95
7.0.290.0150.16017.86
7.0.280.0070.14917.88
7.0.270.0100.15917.88
7.0.260.0180.15217.92
7.0.250.0180.15618.05
7.0.240.0130.15318.23
7.0.230.0200.16518.10
7.0.220.0100.17217.85
7.0.210.0180.15817.95
7.0.200.0080.15418.09
7.0.190.0150.17217.75
7.0.180.0150.15118.11
7.0.170.0180.15518.17
7.0.160.0230.15518.09
7.0.150.0100.15517.84
7.0.140.0130.14817.95
7.0.130.0210.16418.12
7.0.120.0150.16017.99
7.0.110.0100.16217.86
7.0.100.0170.16417.87
7.0.90.0210.16017.89
7.0.80.0160.15418.02
7.0.70.0200.15317.89
7.0.60.0070.16218.13
7.0.50.0130.14817.71
7.0.40.0130.15317.91
7.0.30.0180.16218.10
7.0.20.0100.15318.05
7.0.10.0150.17318.05
7.0.00.0160.15217.65
5.6.400.0130.46916.88
5.6.390.0150.45816.81
5.6.380.0130.42616.79
5.6.370.0130.43316.89
5.6.360.0100.44416.78
5.6.350.0120.44516.72
5.6.340.0170.44316.86
5.6.330.0020.46316.97
5.6.320.0080.47016.91
5.6.310.0020.46916.86
5.6.300.0070.46316.70
5.6.290.0030.46416.80
5.6.280.0150.45016.61
5.6.270.0130.45816.77
5.6.260.0170.44416.85
5.6.250.0090.58216.57
5.6.240.0050.45516.89
5.6.230.0100.43116.94
5.6.220.0080.44016.92
5.6.210.0080.46316.86
5.6.200.0180.44817.01
5.6.190.0050.48216.90
5.6.180.0080.45116.81
5.6.170.0070.45517.02
5.6.160.0050.44916.89
5.6.150.0100.45117.01
5.6.140.0070.45017.01
5.6.130.0080.44316.89
5.6.120.0100.47016.91
5.6.110.0100.47316.85
5.6.100.0120.42816.92
5.6.90.0070.44116.79
5.6.80.0070.43216.90
5.6.70.0120.44816.99
5.6.60.0100.44416.92
5.6.50.0120.47516.72
5.6.40.0050.42716.84
5.6.30.0080.54416.92
5.6.20.0100.44916.73
5.6.10.0080.45516.83
5.6.00.0260.47116.70
5.5.380.0130.47316.95
5.5.370.0200.47416.84
5.5.360.0100.45016.80
5.5.350.0130.46616.88
5.5.340.0070.45816.86
5.5.330.0130.44616.63
5.5.320.0150.45616.72
5.5.310.0200.45316.79
5.5.300.0130.45316.70
5.5.290.0080.46016.69
5.5.280.0150.43516.76
5.5.270.0200.45416.72
5.5.260.0120.48616.72
5.5.250.0150.45216.86
5.5.240.0170.47816.74
5.5.230.0150.45016.64
5.5.220.0170.47716.85
5.5.210.0200.44416.85
5.5.200.0130.49016.57
5.5.190.0100.48316.74
5.5.180.0150.45416.57
5.5.170.0150.46816.72
5.5.160.0080.44916.71
5.5.150.0100.45616.70
5.5.140.0100.45316.57
5.5.130.0080.46216.60
5.5.120.0070.42716.65
5.5.110.0080.47916.63
5.5.100.0120.44116.78
5.5.90.0070.46316.75
5.5.80.0120.47016.86
5.5.70.0150.44716.91
5.5.60.0070.47216.71
5.5.50.0050.44916.84
5.5.40.0150.46317.10
5.5.30.0070.45517.39
5.5.20.0120.44216.72
5.5.10.0120.47416.68
5.5.00.0130.45716.75
5.4.450.0100.47216.25
5.4.440.0080.48416.25
5.4.430.0030.45116.25
5.4.420.0100.45016.25
5.4.410.0030.46916.25
5.4.400.0080.45916.25
5.4.390.0030.47116.25
5.4.380.0070.46916.25
5.4.370.0080.45916.25
5.4.360.0100.47016.25
5.4.350.0070.45316.25
5.4.340.0120.47916.25
5.4.330.0030.46816.25
5.4.320.0030.45816.25
5.4.310.0050.43616.25
5.4.300.0070.43616.25
5.4.290.0150.44516.25
5.4.280.0080.47616.25
5.4.270.0070.47716.25
5.4.260.0030.46516.25
5.4.250.0020.46116.25
5.4.240.0030.46716.25
5.4.230.0100.48216.25
5.4.220.0050.47216.25
5.4.210.0050.46216.25
5.4.200.0080.46416.25
5.4.190.0070.46416.25
5.4.180.0080.46316.25
5.4.170.0100.46316.25
5.4.160.0050.43316.25
5.4.150.0100.44416.25
5.4.140.0100.46416.25
5.4.130.0050.48416.25
5.4.120.0070.45516.25
5.4.110.0080.43516.25
5.4.100.0050.45516.25
5.4.90.0080.44716.25
5.4.80.0050.45916.25
5.4.70.0070.46616.25
5.4.60.0030.45216.25
5.4.50.0100.43916.25
5.4.40.0070.47516.25
5.4.30.0080.47116.25
5.4.20.0030.46416.25
5.4.10.0070.48716.25
5.4.00.0120.48816.25
5.3.290.0050.50016.25
5.3.280.0100.53216.25
5.3.270.0080.47416.25
5.3.260.0050.49816.25
5.3.250.0050.46216.25
5.3.240.0050.50316.25
5.3.230.0030.51416.25
5.3.220.0070.50016.25
5.3.210.0070.51916.25
5.3.200.0150.50716.25
5.3.190.0030.53116.25
5.3.180.0070.50716.25
5.3.170.0100.51116.25
5.3.160.0100.50216.25
5.3.150.0050.49616.25
5.3.140.0070.52616.25
5.3.130.0030.50116.25
5.3.120.0030.50116.25
5.3.110.0030.51616.25
5.3.100.0050.50216.25
5.3.90.0020.52116.25
5.3.80.0050.50316.25
5.3.70.0050.51716.25
5.3.60.0030.51516.25
5.3.50.0030.49716.25
5.3.40.0050.50516.25
5.3.30.0030.52316.25
5.3.20.0070.49216.25
5.3.10.0030.51816.25
5.3.00.0080.50616.25
5.2.170.0030.65316.25
5.2.160.0070.65116.25
5.2.150.0070.61416.25
5.2.140.0020.62816.25
5.2.130.0030.63416.25
5.2.120.0080.64716.25
5.2.110.0050.67716.25
5.2.100.0070.63816.25
5.2.90.0070.66116.25
5.2.80.0030.65116.25
5.2.70.0050.64916.25
5.2.60.0070.65916.25
5.2.50.0030.62816.25
5.2.40.0100.66716.25
5.2.30.0050.63916.25
5.2.20.0120.67116.25
5.2.10.0100.62616.25
5.2.00.0030.73116.25
5.1.60.0050.70916.25
5.1.50.0070.71316.25
5.1.40.0050.75116.25
5.1.30.0020.68516.25
5.1.20.0070.71516.25
5.1.10.0050.72516.25
5.1.00.0070.72916.25
5.0.50.0071.68016.25
5.0.40.0081.71616.25
5.0.30.0071.68816.25
5.0.20.0031.59916.25
5.0.10.0031.67716.25
5.0.00.0031.80716.25
4.4.90.0031.35516.25
4.4.80.0021.26916.25
4.4.70.0031.33116.25
4.4.60.0031.26816.25
4.4.50.0031.17616.25
4.4.40.0051.32916.25
4.4.30.0051.30116.25
4.4.20.0031.35116.25
4.4.10.0001.37316.25
4.4.00.0051.31416.25
4.3.110.0021.30416.25
4.3.100.0031.26116.25
4.3.90.0031.42716.25
4.3.80.0001.51416.25
4.3.70.0051.52616.25
4.3.60.0001.53916.25
4.3.50.0051.54116.25
4.3.40.0001.50016.25
4.3.30.0021.46516.25
4.3.20.0001.52316.25
4.3.10.0051.52716.25
4.3.00.0031.53116.25

preferences:
64.8 ms | 401 KiB | 5 Q