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;<?php

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.3.60.0140.00716.75
8.3.50.0130.00622.75
8.3.40.0030.01218.57
8.3.30.0150.00018.83
8.3.20.0040.00420.16
8.3.10.0000.00821.69
8.3.00.0000.00917.38
8.2.180.0140.00316.50
8.2.170.0070.00722.96
8.2.160.0030.01320.52
8.2.150.0070.01024.18
8.2.140.0080.00024.66
8.2.130.0080.00326.16
8.2.120.0080.00021.09
8.2.110.0060.00322.25
8.2.100.0090.00319.64
8.2.90.0060.00319.23
8.2.80.0030.00617.97
8.2.70.0060.00317.50
8.2.60.0050.00317.80
8.2.50.0060.00318.07
8.2.40.0040.00418.22
8.2.30.0070.00017.96
8.2.20.0030.00517.54
8.2.10.0020.00517.91
8.2.00.0000.00817.53
8.1.280.0070.01125.92
8.1.270.0040.01123.92
8.1.260.0100.01026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.67
8.1.230.0040.00819.15
8.1.220.0080.00017.74
8.1.210.0090.00018.77
8.1.200.0030.00617.23
8.1.190.0090.00017.10
8.1.180.0080.00018.10
8.1.170.0050.00318.48
8.1.160.0000.00721.80
8.1.150.0000.00718.73
8.1.140.0020.00517.27
8.1.130.0030.00317.67
8.1.120.0040.00417.38
8.1.110.0000.00717.22
8.1.100.0030.00417.27
8.1.90.0040.00317.16
8.1.80.0030.00317.36
8.1.70.0030.00317.27
8.1.60.0030.00617.32
8.1.50.0030.00617.37
8.1.40.0040.00417.30
8.1.30.0040.00417.41
8.1.20.0050.00317.41
8.1.10.0040.00417.41
8.1.00.0000.00817.34
8.0.300.0030.00318.77
8.0.290.0040.00416.58
8.0.280.0030.00518.25
8.0.270.0030.00317.09
8.0.260.0000.00617.21
8.0.250.0030.00316.69
8.0.240.0030.00316.73
8.0.230.0030.00316.85
8.0.220.0070.00016.75
8.0.210.0070.00016.79
8.0.200.0000.00616.78
8.0.190.0030.00316.85
8.0.180.0040.00416.66
8.0.170.0000.00816.82
8.0.160.0030.00516.78
8.0.150.0030.00316.57
8.0.140.0060.00316.73
8.0.130.0000.00513.31
8.0.120.0030.00516.70
8.0.110.0040.00416.63
8.0.100.0000.00716.73
8.0.90.0040.00416.72
8.0.80.0030.01216.73
8.0.70.0000.00716.70
8.0.60.0040.00416.63
8.0.50.0000.00816.70
8.0.30.0070.01516.98
8.0.20.0110.00817.40
8.0.10.0000.00716.76
8.0.00.0070.01016.60
7.4.330.0030.00315.00
7.4.320.0030.00316.31
7.4.300.0000.00616.38
7.4.290.0000.00716.31
7.4.280.0070.00016.49
7.4.270.0000.00716.41
7.4.260.0000.00716.27
7.4.250.0020.00516.31
7.4.240.0040.00416.39
7.4.230.0000.00716.16
7.4.220.0140.00416.47
7.4.210.0110.00516.49
7.4.200.0070.00016.45
7.4.160.0100.00716.45
7.4.150.0180.00017.40
7.4.140.0090.01017.86
7.4.130.0050.01216.37
7.4.120.0090.00816.39
7.4.110.0060.01616.36
7.4.100.0000.01516.40
7.4.90.0090.00916.34
7.4.80.0070.01019.39
7.4.70.0090.00916.46
7.4.60.0030.01316.39
7.4.50.0000.00516.20
7.4.40.0080.01516.26
7.4.30.0130.00716.16
7.3.330.0060.00013.22
7.3.320.0030.00213.07
7.3.310.0000.00716.28
7.3.300.0040.00316.07
7.3.290.0080.00616.11
7.3.280.0080.01016.13
7.3.270.0100.00717.40
7.3.260.0120.00416.37
7.3.250.0060.01116.23
7.3.240.0090.01316.18
7.3.230.0080.01116.39
7.3.210.0030.01416.06
7.3.200.0060.01119.39
7.3.190.0070.01416.07
7.3.180.0060.00916.23
7.3.170.0080.00816.27
7.3.160.0100.00616.12
7.2.330.0110.01116.43
7.2.320.0160.00316.54
7.2.310.0130.00416.48
7.2.300.0060.01516.25
7.2.290.0060.01016.13
5.5.150.0100.07020.12
5.5.140.0170.07020.10
5.5.130.0130.04720.27
5.5.120.0130.07320.26
5.5.110.0030.06020.23
5.5.100.0070.04320.13
5.5.90.0000.08720.04
5.5.80.0100.07719.93
5.5.70.0030.06320.14
5.5.60.0170.06020.04
5.5.50.0070.04020.07
5.5.40.0100.07320.04
5.5.30.0070.07320.04
5.5.20.0030.08719.98
5.5.10.0070.07320.04
5.5.00.0070.04020.04
5.4.310.0070.05719.23
5.4.300.0070.06319.04
5.4.290.0070.07719.18
5.4.280.0130.07719.02
5.4.270.0030.07719.18
5.4.260.0070.06019.20
5.4.250.0100.06719.21
5.4.240.0030.07719.02
5.4.230.0070.07018.94
5.4.220.0000.08318.84
5.4.210.0070.07719.13
5.4.200.0070.08019.04
5.4.190.0100.06019.08
5.4.180.0170.06719.04
5.4.170.0100.06019.15
5.4.160.0030.08019.01
5.4.150.0170.03319.14
5.4.140.0200.06716.42
5.4.130.0000.04316.43
5.4.120.0100.07016.41
5.4.110.0070.07016.36
5.4.100.0030.07016.27
5.4.90.0070.05316.47
5.4.80.0030.03716.50
5.4.70.0030.06716.31
5.4.60.0070.06716.41
5.4.50.0070.07016.29
5.4.40.0030.08016.39
5.4.30.0100.06316.40
5.4.20.0130.06316.44
5.4.10.0100.07716.42
5.4.00.0030.08015.86
5.3.290.0100.06314.52
5.3.280.0030.04314.54
5.3.270.0070.07014.46
5.3.260.0130.07314.44
5.3.250.0030.08014.59
5.3.240.0030.07714.54
5.3.230.0070.07314.55
5.3.220.0030.07714.55
5.3.210.0030.08014.41
5.3.200.0130.07314.55
5.3.190.0100.05314.42
5.3.180.0100.07014.57
5.3.170.0070.07714.56
5.3.160.0100.06714.46
5.3.150.0100.07014.38
5.3.140.0030.08014.41
5.3.130.0170.06714.52
5.3.120.0070.07714.48
5.3.110.0170.06714.38
5.3.100.0070.07313.95
5.3.90.0130.07013.86
5.3.80.0070.07713.97
5.3.70.0170.07013.87
5.3.60.0130.07313.96
5.3.50.0070.05713.93
5.3.40.0070.07013.93
5.3.30.0030.06713.88
5.3.20.0000.07713.54
5.3.10.0000.07313.43
5.3.00.0070.07013.50
5.2.170.0100.06312.87
5.2.160.0030.06312.87
5.2.150.0030.06012.87
5.2.140.0000.05712.87
5.2.130.0070.06312.87
5.2.120.0070.06012.87
5.2.110.0070.05712.87
5.2.100.0030.06012.87
5.2.90.0130.05712.87
5.2.80.0070.06012.87
5.2.70.0100.05312.87
5.2.60.0070.04312.87
5.2.50.0070.06012.87
5.2.40.0130.05312.87
5.2.30.0030.06012.87
5.2.20.0070.06012.87
5.2.10.0030.06012.87
5.2.00.0030.05012.87
5.1.60.0030.05712.87
5.1.50.0030.05312.87
5.1.40.0030.05012.87
5.1.30.0030.04312.87
5.1.20.0000.04312.87
5.1.10.0030.05312.87
5.1.00.0100.04712.87
5.0.50.0030.04012.87
5.0.40.0030.04312.87
5.0.30.0000.06012.87
5.0.20.0000.04012.87
5.0.10.0070.04012.87
5.0.00.0100.05312.87
4.4.90.0000.03312.87
4.4.80.0000.03712.87
4.4.70.0100.03012.87
4.4.60.0000.03712.87
4.4.50.0070.03012.87
4.4.40.0000.05712.87
4.4.30.0000.03712.87
4.4.20.0100.02712.87
4.4.10.0030.02712.87
4.4.00.0030.05712.87
4.3.110.0000.04012.87
4.3.100.0100.02712.87
4.3.90.0000.03012.87
4.3.80.0000.05312.87
4.3.70.0030.03312.87
4.3.60.0030.02712.87
4.3.50.0070.03012.87
4.3.40.0030.04712.87
4.3.30.0030.03012.87
4.3.20.0000.03012.87
4.3.10.0000.03712.87
4.3.00.0030.03312.87

preferences:
32.84 ms | 401 KiB | 5 Q