3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = '🧪 test'; $encodings = ['utf-8', 'utf-16', 'utf-32']; foreach ($encodings as $to) { var_dump([ 'to' => $to, 'mb_substr' => mb_substr($input, 3, 4, $to), 'iconv_substr' => iconv_substr($input, 3, 4, $to), 'substr' => substr($input, 3, 4), 'substr+utf8_encode' => substr(utf8_encode($input), 3, 4), 'substr+utf8_decode' => substr(utf8_decode($input), 3, 4) ]); }

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.5.70.0070.00917.11
8.5.60.0060.00216.93
8.5.50.0110.00717.01
8.5.30.0100.00719.40
8.5.20.0110.00819.61
8.5.10.0090.00917.03
8.5.00.0120.01020.07
8.4.220.0100.00719.67
8.4.210.0140.00819.91
8.4.180.0140.01019.88
8.4.170.0130.01020.50
8.4.160.0170.00822.40
8.4.150.0080.00516.96
8.4.140.0070.01417.36
8.4.130.0100.00817.87
8.4.120.0080.01224.20
8.4.110.0120.00821.87
8.4.100.0070.00820.48
8.4.90.0150.00619.00
8.4.80.0060.00518.77
8.4.70.0060.00420.69
8.4.60.0140.00719.00
8.4.50.0110.00918.40
8.4.40.0130.00717.71
8.4.30.0130.01020.39
8.4.20.0070.01018.17
8.4.10.0130.00718.03
8.3.310.0130.00918.59
8.3.300.0170.00420.95
8.3.290.0100.01120.60
8.3.280.0090.01118.40
8.3.270.0130.00816.84
8.3.260.0060.00317.06
8.3.250.0100.00918.80
8.3.240.0150.00517.08
8.3.230.0030.00616.91
8.3.220.0080.00119.05
8.3.210.0080.01016.97
8.3.200.0070.00216.66
8.3.190.0080.01117.26
8.3.180.0110.00917.25
8.3.170.0150.00422.77
8.3.160.0120.00617.20
8.3.150.0060.00917.25
8.3.140.0040.00416.82
8.3.130.0050.00516.61
8.3.120.0130.00318.93
8.3.110.0160.00316.89
8.3.100.0100.00016.60
8.3.90.0000.00726.77
8.3.80.0030.00619.36
8.3.70.0130.00616.59
8.3.60.0150.00018.68
8.3.50.0120.00616.41
8.3.40.0070.01118.66
8.3.30.0070.00718.85
8.3.20.0040.00424.18
8.3.10.0100.01024.66
8.3.00.0040.00426.16
8.2.300.0100.01022.23
8.2.290.0110.00720.55
8.2.280.0110.00718.40
8.2.270.0100.01017.22
8.2.260.0040.00416.84
8.2.250.0060.00318.55
8.2.240.0030.00617.29
8.2.230.0090.00620.94
8.2.220.0050.00537.54
8.2.210.0030.00526.77
8.2.200.0060.00318.88
8.2.190.0070.01118.29
8.2.180.0120.00925.92
8.2.170.0120.00319.07
8.2.160.0100.00322.96
8.2.150.0050.00225.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00426.35
8.2.110.0000.01121.00
8.2.100.0080.00417.91
8.2.90.0000.00819.17
8.2.80.0030.00517.97
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0000.00818.07
8.2.40.0050.00318.21
8.2.30.0040.00418.10
8.2.20.0000.00818.11
8.2.10.0040.00419.32
8.2.00.0000.00719.22
8.1.340.0100.01117.80
8.1.330.0130.00722.05
8.1.320.0130.00716.21
8.1.310.0040.00416.37
8.1.300.0000.00820.30
8.1.290.0060.00330.84
8.1.280.0180.00325.92
8.1.270.0080.00023.91
8.1.260.0060.00328.09
8.1.250.0070.00028.09
8.1.240.0040.00420.91
8.1.230.0000.01017.82
8.1.220.0060.00317.74
8.1.210.0060.00318.77
8.1.200.0000.00817.35
8.1.190.0040.00417.47
8.1.180.0060.00318.10
8.1.170.0030.00618.56
8.1.160.0040.00418.83
8.1.150.0030.00518.95
8.1.140.0040.00418.86
8.1.130.0000.00720.25
8.1.120.0030.00617.57
8.1.110.0030.00617.37
8.1.100.0050.00217.54
8.1.90.0030.00517.50
8.1.80.0070.00017.46
8.1.70.0090.00017.49
8.1.60.0080.00017.57
8.1.50.0040.00417.62
8.1.40.0040.00417.63
8.1.30.0080.00317.61
8.1.20.0000.00817.71
8.1.10.0040.00417.50
8.1.00.0030.00517.50
8.0.300.0000.00718.77
8.0.290.0040.00416.88
8.0.280.0070.00018.42
8.0.270.0040.00418.01
8.0.260.0030.00318.50
8.0.250.0040.00417.07
8.0.240.0080.00016.97
8.0.230.0020.00517.06
8.0.220.0070.00017.03
8.0.210.0050.00316.92
8.0.200.0060.00017.04
8.0.190.0030.00617.09
8.0.180.0000.00716.94
8.0.170.0040.00416.92
8.0.160.0030.00517.05
8.0.150.0000.00717.07
8.0.140.0030.00617.04
8.0.130.0000.00613.42
8.0.120.0030.00817.12
8.0.110.0050.00517.04
8.0.100.0000.01017.25
8.0.90.0030.00617.01
8.0.80.0060.01217.17
8.0.70.0000.00917.27
8.0.60.0000.01017.09
8.0.50.0050.00517.08
8.0.30.0060.01517.22
8.0.20.0100.01017.23
8.0.10.0100.01717.30
8.0.00.0150.01217.32
7.4.330.0030.00315.55
7.4.320.0030.00316.66
7.4.300.0000.00716.48
7.4.290.0050.00216.53
7.4.280.0000.00816.68
7.4.270.0000.00816.58
7.4.260.0050.00013.25
7.4.250.0050.00516.82
7.4.240.0030.00616.63
7.4.230.0050.00516.68
7.4.220.0040.00716.77
7.4.210.0060.01416.85
7.4.200.0000.00916.86
7.4.160.0070.01516.77
7.4.150.0200.00016.80
7.4.140.0110.00816.74
7.4.130.0140.01116.71
7.4.120.0060.01916.52
7.4.110.0030.02316.68
7.4.100.0130.01316.76
7.4.90.0120.01616.62
7.4.80.0080.01516.61
7.4.70.0090.00916.70
7.4.60.0030.01616.69
7.4.50.0200.01016.57
7.4.40.0100.01716.58
7.4.30.0100.01016.64
7.4.20.0070.01316.79
7.4.10.0130.00816.54
7.4.00.0180.01116.58
7.3.330.0050.00216.29
7.3.320.0060.00013.12
7.3.310.0030.00616.47
7.3.300.0040.00416.51
7.3.290.0070.01216.68
7.3.270.0080.01616.62
7.3.260.0140.01116.69
7.3.250.0110.01416.63
7.3.240.0100.01416.70
7.3.230.0100.01416.58
7.3.220.0100.01016.69
7.3.210.0090.01616.63
7.3.200.0120.00916.63
7.3.190.0090.00916.53
7.3.180.0050.01516.64
7.3.170.0170.01116.54
7.3.160.0090.01116.58
7.3.150.0120.01816.60
7.3.140.0130.01316.52
7.3.130.0120.01416.55
7.3.120.0070.01616.54
7.3.110.0130.01316.48
7.3.100.0070.01416.47
7.3.90.0000.02016.81
7.3.80.0120.01216.70
7.3.70.0220.00316.51
7.3.60.0170.01116.62
7.3.50.0130.01316.60
7.3.40.0060.01616.68
7.3.30.0120.00916.73
7.3.20.0030.02116.70
7.3.10.0080.01616.59
7.3.00.0100.01016.58

preferences:
52.08 ms | 1643 KiB | 5 Q