3v4l.org

run code in 300+ PHP versions simultaneously
<?php $examples = array( 'Valid ASCII' => array("a", true), 'Valid 2 Octet Sequence' => array("\xc3\xb1", true), 'Invalid 2 Octet Sequence' => array("\xc3\x28", false), 'Invalid Sequence Identifier' => array("\xa0\xa1", false), 'Valid 3 Octet Sequence' => array("\xe2\x82\xa1", true), 'Invalid 3 Octet Sequence (in 2nd Octet)' => array("\xe2\x28\xa1", false), 'Invalid 3 Octet Sequence (in 3rd Octet)' => array("\xe2\x82\x28", false), 'Valid 4 Octet Sequence' => array("\xf0\x90\x8c\xbc", true), 'Invalid 4 Octet Sequence (in 2nd Octet)' => array("\xf0\x28\x8c\xbc", false), 'Invalid 4 Octet Sequence (in 3rd Octet)' => array("\xf0\x90\x28\xbc", false), 'Invalid 4 Octet Sequence (in 4th Octet)' => array("\xf0\x28\x8c\x28", false), 'Valid 5 Octet Sequence (but not Unicode!)' => array("\xf8\xa1\xa1\xa1\xa1", false), 'Valid 6 Octet Sequence (but not Unicode!)' => array("\xfc\xa1\xa1\xa1\xa1\xa1", false), ); function checkWithPreg($str) { return preg_match('//u', $str); } function checkWithMbstring($str) { return mb_check_encoding($str, 'UTF-8'); } function runTests($method, $count) { global $examples; $start_m = microtime(); $start = time(); for($i=0; $i<$count; $i++) { foreach($examples as $title => $arr) { list($str, $bool) = $arr; $method($str); } } $end_m = microtime(); $end = time(); $bench = ($end - $start) + ($end_m - $start_m); echo "$method $bench\n"; } runTests('checkWithMbstring', 10000); runTests('checkWithPreg', 10000);

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.4.00.0000.24615.07
7.3.120.0030.23815.11
7.3.110.0100.22815.23
7.3.100.0070.16215.21
7.3.90.0030.25315.45
7.3.80.0070.15415.16
7.3.70.0130.21114.90
7.3.60.0070.17114.93
7.3.50.0030.16615.13
7.3.40.0030.19115.25
7.3.30.0100.18315.11
7.3.20.0100.16817.05
7.3.10.0040.17316.84
7.3.00.0070.15516.67
7.2.250.0100.26815.23
7.2.240.0070.27415.17
7.2.230.0100.17315.50
7.2.220.0100.26115.32
7.2.210.0030.19615.05
7.2.200.0030.17815.44
7.2.190.0100.18715.32
7.2.180.0030.17115.30
7.2.170.0030.17215.14
7.2.130.0070.18317.09
7.2.120.0100.19017.06
7.2.110.0120.19617.01
7.2.100.0050.18517.04
7.2.90.0130.19316.78
7.2.80.0140.18216.93
7.2.70.0110.19217.07
7.2.60.0070.18917.04
7.2.50.0160.16817.13
7.2.40.0080.19716.92
7.2.30.0080.19417.10
7.2.20.0100.20317.11
7.2.10.0080.22616.94
7.2.00.0030.17517.86
7.1.330.0030.23315.89
7.1.320.0070.27316.14
7.1.310.0030.22016.03
7.1.300.0100.24016.18
7.1.290.0100.21216.12
7.1.280.0070.24016.16
7.1.270.0030.22015.82
7.1.260.0030.23416.06
7.1.250.0130.25115.99
7.1.240.0000.27015.73
7.1.230.0100.24115.92
7.1.220.0100.21615.90
7.1.210.0030.21615.85
7.1.200.0030.22316.13
7.1.190.0000.21616.01
7.1.180.0100.23416.00
7.1.170.0100.23416.19
7.1.160.0030.26516.00
7.1.150.0070.25515.85
7.1.140.0030.26216.14
7.1.130.0100.28916.13
7.1.120.0030.23316.16
7.1.110.0030.21916.16
7.1.100.0030.22316.03
7.1.90.0070.23516.11
7.1.80.0030.22515.69
7.1.70.0250.19216.74
7.1.60.0070.19517.59
7.1.50.0100.18116.56
7.1.40.0030.23816.10
7.1.30.0130.24116.10
7.1.20.0000.24716.05
7.1.10.0030.23915.99
7.1.00.0050.23819.11
7.0.330.0130.25115.37
7.0.320.0030.21115.29
7.0.310.0070.21815.38
7.0.300.0030.23615.29
7.0.290.0100.25015.40
7.0.280.0070.24515.57
7.0.270.0000.25615.63
7.0.260.0100.22715.56
7.0.250.0130.23615.46
7.0.240.0030.22915.45
7.0.230.0030.22615.52
7.0.220.0100.25115.67
7.0.210.0130.22515.61
7.0.200.0020.18616.21
7.0.190.0130.22115.60
7.0.180.0030.25615.62
7.0.170.0030.23015.52
7.0.160.0130.24715.39
7.0.150.0100.23415.30
7.0.140.0080.23818.85
7.0.130.0030.24015.63
7.0.120.0030.22715.43
7.0.110.0070.22515.58
7.0.100.0030.22217.66
7.0.90.0200.22017.79
7.0.80.0070.23317.67
7.0.70.0030.20217.65
7.0.60.0080.22417.80
7.0.50.0080.18817.96
7.0.40.0050.20516.71
7.0.30.0070.19716.82
7.0.20.0070.20816.79
7.0.10.0030.22616.79
7.0.00.0070.20416.86
5.6.380.0100.27614.16
5.6.370.0000.27614.62
5.6.360.0030.27214.39
5.6.350.0000.29314.40
5.6.340.0070.30714.46
5.6.330.0000.29114.46
5.6.320.0070.26914.49
5.6.310.0030.28514.64
5.6.300.0070.28214.46
5.6.290.0070.29714.09
5.6.280.0020.28917.71
5.6.270.0070.27914.19
5.6.260.0030.30514.27
5.6.250.0070.25417.40
5.6.240.0030.29217.55
5.6.230.0080.28517.54
5.6.220.0050.23917.34
5.6.210.0070.26317.60
5.6.200.0080.25317.76
5.6.190.0050.26717.86
5.6.180.0020.25217.74
5.6.170.0020.26517.65
5.6.160.0050.30517.54
5.6.150.0050.29917.54
5.6.140.0080.27717.66
5.6.130.0030.30417.69
5.6.120.0130.27617.72
5.6.110.0130.27217.68
5.6.100.0050.26917.79
5.6.90.0050.27017.88
5.6.80.0050.28817.35
5.6.70.0070.29217.38
5.6.60.0030.27117.40
5.6.50.0120.25417.33
5.6.40.0070.27117.33
5.6.30.0070.25717.22
5.6.20.0030.29017.20
5.6.10.0080.29017.23
5.6.00.0000.27017.29
5.5.380.0080.29015.60
5.5.370.0030.28915.84
5.5.360.0070.27215.89
5.5.350.0020.27115.79
5.5.340.0020.29416.09
5.5.330.0020.27316.14
5.5.320.0030.28016.06
5.5.310.0050.29515.94
5.5.300.0080.30916.05
5.5.290.0050.30516.01
5.5.280.0050.28916.07
5.5.270.0080.26516.03
5.5.260.0070.26016.05
5.5.250.0050.27516.00
5.5.240.0070.29215.76
5.5.230.0120.28015.58
5.5.220.0250.27015.69
5.5.210.0000.29415.63
5.5.200.0020.30015.69
5.5.190.0030.26715.87
5.5.180.0070.25715.64
5.5.170.0070.29711.23
5.5.160.0100.30015.48
5.5.150.0070.28715.60
5.5.140.0050.29015.65
5.5.130.0100.28715.68
5.5.120.0070.27415.67
5.5.110.0130.28615.69
5.5.100.0070.28115.60
5.5.90.0070.26615.54
5.5.80.0050.29715.55
5.5.70.0020.29015.58
5.5.60.0080.28815.58
5.5.50.0080.26215.70
5.5.40.0080.28215.69
5.5.30.0050.28815.72
5.5.20.0020.29515.61
5.5.10.0020.30915.61
5.5.00.0070.28115.49
5.4.450.0070.31315.37
5.4.440.0050.29215.23
5.4.430.0050.29415.22
5.4.420.0280.27115.36
5.4.410.0030.30515.21
5.4.400.0100.30215.02
5.4.390.0050.29115.13
5.4.380.0050.25715.05
5.4.370.0030.29114.87
5.4.360.0070.27815.08
5.4.350.0050.27815.20
5.4.340.0030.27715.15
5.4.330.0070.32811.05
5.4.320.0030.31514.91
5.4.310.0050.30114.91
5.4.300.0000.26415.15
5.4.290.0050.29915.09
5.4.280.0070.26614.99
5.4.270.0030.29015.09
5.4.260.0030.30615.14
5.4.250.0100.29715.20
5.4.240.0030.29515.03
5.4.230.0050.28915.16
5.4.220.0100.27215.17
5.4.210.0050.30214.99
5.4.200.0220.28315.23
5.4.190.0020.29115.16
5.4.180.0070.28014.95
5.4.170.0000.28015.01
5.4.160.0070.29015.06
5.4.150.0070.28715.21
5.4.140.0120.27713.79
5.4.130.0160.27913.68
5.4.120.0050.28013.67
5.4.110.0030.26213.81
5.4.100.0020.28313.68
5.4.90.0050.28013.81
5.4.80.0030.26614.00
5.4.70.0080.27413.77
5.4.60.0030.28413.91
5.4.50.0070.30613.74
5.4.40.0080.30013.74
5.4.30.0100.29013.62
5.4.20.0050.27513.80
5.4.10.0050.31213.80
5.4.00.0030.30513.43
5.3.290.0050.31012.71
5.3.280.0070.30112.62
5.3.270.0030.30612.58
5.3.260.0050.28912.66
5.3.250.0030.32012.77
5.3.240.0030.29612.61
5.3.230.0070.28712.57
5.3.220.0070.30612.66
5.3.210.0080.30312.58
5.3.200.0050.30412.66
5.3.190.0000.30312.72
5.3.180.0050.30312.64
5.3.170.0050.28812.55
5.3.160.0070.32512.50
5.3.150.0020.32812.70
5.3.140.0080.29012.68
5.3.130.0070.31312.58
5.3.120.0050.31012.67
5.3.110.0020.29712.58
5.3.100.0000.31612.28
5.3.90.0070.28912.43
5.3.80.0070.29412.34
5.3.70.0080.33112.35
5.3.60.0050.35012.44
5.3.50.0070.32712.25
5.3.40.0100.30512.31
5.3.30.0020.31112.21
5.3.20.0020.32312.14
5.3.10.0070.30012.04
5.3.00.0100.27212.05
5.2.170.0030.35810.67
5.2.160.0020.34010.67
5.2.150.0030.34210.67
5.2.140.0020.34810.67
5.2.130.0000.31910.67
5.2.120.0080.34210.67
5.2.110.0030.32210.67
5.2.100.0050.33610.67
5.2.90.0070.33010.67
5.2.80.0020.34410.67
5.2.70.0050.33210.67
5.2.60.0050.32610.67
5.2.50.0030.33810.67
5.2.40.0030.34610.67
5.2.30.0080.30010.67
5.2.20.0020.33810.67
5.2.10.0120.29910.67
5.2.00.0030.31110.67
5.1.60.0030.33810.67
5.1.50.0030.33810.67
5.1.40.0050.33010.67
5.1.30.0000.31710.67
5.1.20.0030.01510.67
5.1.10.0020.01610.67
5.1.00.0020.01810.67
5.0.50.0000.01310.67
5.0.40.0020.01210.67
5.0.30.0020.01710.67
5.0.20.0020.01510.67
5.0.10.0050.00810.67
5.0.00.0020.01310.67
4.4.90.0030.49310.67
4.4.80.0070.52510.67
4.4.70.0020.54510.67
4.4.60.0030.53710.67
4.4.50.0020.54410.67
4.4.40.0020.48810.67
4.4.30.0220.48410.67
4.4.20.0000.01210.67
4.4.10.0020.00810.67
4.4.00.0000.02010.67
4.3.110.0000.01210.67
4.3.100.0000.01010.67
4.3.90.0020.00710.67
4.3.80.0010.01310.67
4.3.70.0030.00910.67
4.3.60.0040.00710.67
4.3.50.0000.01210.67
4.3.40.0020.01510.67
4.3.30.0000.01210.67
4.3.20.0000.01010.67
4.3.10.0020.00910.67
4.3.00.0000.01010.67

preferences:
39.1 ms | 401 KiB | 5 Q