3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Compare building an array an in_array()ing it, vs a regex check */ $runs = 1000000; // in_array $t = microtime(true); for ($i = 0; $i < $runs; $i++) { if (in_array('test', ['foo','bar','baz','fooby','bario','xyz','abc','def','ghi','jkl','mno','pqr','stu','vwx'])); } $t -= microtime(true); echo 'in_array: ', $t, PHP_EOL; // preg_match $t = microtime(true); for ($i = 0; $i < $runs; $i++) { if (preg_match('/^(foo|bar|baz|fooby|bario|xyz|abc|def|ghi|jkl|mno|pqr|stu|vwx)$/', 'test')); } $t -= microtime(true); echo 'preg_match: ', $t, PHP_EOL;

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.2.00.0000.12119.73
7.1.70.0100.16717.18
7.1.60.0070.21019.40
7.1.50.0100.18617.11
7.1.00.0000.27322.30
7.0.200.0030.23617.00
7.0.140.0030.35721.98
7.0.60.0100.35019.82
7.0.50.0100.36017.95
7.0.40.0100.30320.02
7.0.30.0670.33020.06
7.0.20.0300.36020.11
7.0.10.0130.32020.19
7.0.00.0130.30320.22
5.6.280.0071.68321.10
5.6.210.0071.63720.75
5.6.200.0131.62018.18
5.6.190.0071.59720.77
5.6.180.3901.53720.33
5.6.170.0371.61020.45
5.6.160.0031.59020.32
5.6.150.0031.65718.20
5.6.140.3731.55018.15
5.6.130.0031.66718.07
5.6.120.0071.67320.98
5.6.110.0001.66020.97
5.6.100.0031.65720.95
5.6.90.0101.67021.01
5.6.80.0031.67320.38
5.6.70.0171.64020.50
5.5.350.0231.57320.42
5.5.340.0101.64018.00
5.5.330.0071.63320.19
5.5.320.0501.65020.29
5.5.310.0271.67320.41
5.5.300.0031.62718.01
5.5.290.0031.70017.91
5.5.280.0071.70320.88
5.5.270.0031.70320.75
5.5.260.1371.66020.86
5.5.250.0101.69720.61
5.5.240.3731.38720.19
5.4.450.0972.37719.54
5.4.440.0572.27319.15
5.4.430.0902.28719.49
5.4.420.0702.10319.38
5.4.410.0832.19319.35
5.4.400.0772.18319.14
5.4.390.0632.13719.21
5.4.380.0102.21318.49
5.4.370.0131.93018.50
5.4.360.0101.97318.57
5.4.350.0072.00311.98
5.4.340.0172.02411.97
5.4.320.0071.67212.45
5.4.310.0092.00812.45
5.4.300.0171.79812.46
5.4.290.0121.78512.45
5.4.280.0121.96312.35
5.4.270.0121.90212.35
5.4.260.0191.74212.35
5.4.250.0091.71212.35
5.4.240.0201.73712.35
5.4.230.0121.80512.34
5.4.220.0111.71512.34
5.4.210.0041.69212.34
5.4.200.0091.99612.34
5.4.190.0182.03312.34
5.4.180.0141.87912.34
5.4.170.0111.78412.35
5.4.160.0181.97812.34
5.4.150.0121.81312.34
5.4.140.0151.75412.02
5.4.130.0111.72012.01
5.4.120.0141.80311.97
5.4.110.0101.85711.97
5.4.100.0211.84711.96
5.4.90.0121.83711.97
5.4.80.0131.92711.96
5.4.70.0151.86311.96
5.4.60.0181.88511.96
5.4.50.0081.84611.96
5.4.40.0091.84611.95
5.4.30.0111.85911.95
5.4.20.0101.99611.95
5.4.10.0141.84811.95
5.4.00.0111.86911.45
5.3.290.0080.04312.80
5.3.280.0090.03412.71
5.3.270.0080.03812.73
5.3.260.0040.04012.71
5.3.250.0090.04712.72
5.3.240.0070.04312.72
5.3.230.0060.03812.71
5.3.220.0080.03512.68
5.3.210.0050.04012.68
5.3.200.0050.03612.68
5.3.190.0070.03612.68
5.3.180.0050.04112.67
5.3.170.0080.03612.67
5.3.160.0060.03712.67
5.3.150.0070.03612.68
5.3.140.0050.03612.66
5.3.130.0030.04212.66
5.3.120.0080.03512.66
5.3.110.0060.03912.66
5.3.100.0080.03612.12
5.3.90.0080.03412.08
5.3.80.0070.03512.08
5.3.70.0030.03912.08
5.3.60.0090.03312.06
5.3.50.0060.03612.00
5.3.40.0050.03712.00
5.3.30.0050.03611.95
5.3.20.0060.03411.72
5.3.10.0060.03311.70
5.3.00.0010.04011.69
5.2.170.0020.0339.18
5.2.160.0050.0299.19
5.2.150.0020.0379.18
5.2.140.0050.0309.18
5.2.130.0080.0259.14
5.2.120.0060.0279.14
5.2.110.0070.0269.14
5.2.100.0070.0269.14
5.2.90.0060.0289.14
5.2.80.0050.0299.14
5.2.70.0040.0309.14
5.2.60.0080.0269.09
5.2.50.0070.0399.06
5.2.40.0090.0269.03
5.2.30.0060.0289.01
5.2.20.0040.0299.00
5.2.10.0060.0288.92
5.2.00.0020.0318.79
5.1.60.0050.0228.07
5.1.50.0040.0248.06
5.1.40.0030.0258.04
5.1.30.0030.0278.40
5.1.20.0050.0258.41
5.1.10.0030.0278.15
5.1.00.0030.0268.14
5.0.50.0060.0186.63
5.0.40.0030.0196.48
5.0.30.0050.0306.30
5.0.20.0040.0196.26
5.0.10.0020.0216.25
5.0.00.0040.0306.23
4.4.90.0010.0174.78
4.4.80.0020.0164.76
4.4.70.0050.0134.76
4.4.60.0010.0174.75
4.4.50.0030.0154.77
4.4.40.0040.0244.71
4.4.30.0040.0144.76
4.4.20.0020.0164.84
4.4.10.0050.0134.85
4.4.00.0030.0254.76
4.3.110.0030.0154.67
4.3.100.0030.0144.67
4.3.90.0040.0134.63
4.3.80.0040.0234.59
4.3.70.0050.0124.63
4.3.60.0030.0154.62
4.3.50.0030.0164.62
4.3.40.0020.0254.54
4.3.30.0020.0163.28
4.3.20.0050.0153.26
4.3.10.0030.0153.23
4.3.00.0200.0237.10

preferences:
38.12 ms | 400 KiB | 5 Q