3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo1($string, $with) { if (!$bytes = static::byteLength($with)) { return true; } // Warning check, see http://php.net/manual/en/function.substr-compare.php#refsect1-function.substr-compare-returnvalues if (static::byteLength($string) < $bytes) { return false; } return substr_compare($string, $with, -$bytes); } function foo2($string, $with) { if (!$bytes = static::byteLength($with)) { return true; } // Warning check, see http://php.net/manual/en/function.substr-compare.php#refsect1-function.substr-compare-returnvalues if (static::byteLength($string) < $bytes) { return false; } return substr_compare($string, $with, -$bytes, $bytes); } var_dump(foo1('a', 'a')); var_dump(foo2('a', 'a')); var_dump(foo1('', '')); var_dump(foo2('', '')); var_dump(foo1('a', '')); var_dump(foo2('a', '')); var_dump(foo1('', 'a')); var_dump(foo2('', 'a'));

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)
5.4.320.3930.03318.94
5.4.310.4000.03719.22
5.4.300.4370.03719.17
5.4.290.4030.04019.04
5.4.280.4330.04019.16
5.4.270.4700.04019.23
5.4.260.3930.03718.92
5.4.250.3600.03719.13
5.4.240.3430.04319.21
5.4.230.2700.04019.16
5.4.220.2470.03019.13
5.4.210.3470.03719.09
5.4.200.3430.04018.91
5.4.190.2970.03719.12
5.4.180.2470.03019.12
5.4.170.2500.04019.21
5.4.160.2630.03319.20
5.4.150.3000.03719.20
5.4.140.3700.03716.43
5.4.130.3730.03016.30
5.4.120.4300.03316.50
5.4.110.4430.03716.56
5.4.100.3830.04016.49
5.4.90.4070.04016.68
5.4.80.4370.03716.29
5.4.70.4670.04016.56
5.4.60.3830.03316.44
5.4.50.4800.03716.30
5.4.40.4770.03716.61
5.4.30.4830.03716.29
5.4.20.5000.04016.44
5.4.10.0030.04316.42
5.4.00.0030.07715.79
5.3.290.3830.04014.84
5.3.280.1570.04014.60
5.3.270.2830.04014.68
5.3.260.2770.03714.64
5.3.250.3730.03014.64
5.3.240.3870.03314.67
5.3.230.4630.04014.52
5.3.220.3200.03714.46
5.3.210.3970.04714.57
5.3.200.4070.03314.64
5.3.190.3800.03314.47
5.3.180.3970.04314.62
5.3.170.4300.03714.58
5.3.160.4600.03714.72
5.3.150.4200.03714.56
5.3.140.4730.04014.65
5.3.130.5970.03714.57
5.3.120.4770.03714.58
5.3.110.4100.04014.45
5.3.100.0070.06014.04
5.3.90.2670.04013.95
5.3.80.4330.04013.99
5.3.70.3670.03714.18
5.3.60.3730.03713.96
5.3.50.3970.04013.98
5.3.40.4300.04713.96
5.3.30.4530.03713.86
5.3.20.5900.03313.74
5.3.10.3870.04013.67
5.3.00.4070.03713.61
5.2.170.3570.03711.16
5.2.160.4230.03011.20
5.2.150.3730.03311.22
5.2.140.3470.02311.13
5.2.130.3470.03311.10
5.2.120.3300.02711.25
5.2.110.3270.02711.17
5.2.100.3170.03010.99
5.2.90.3330.02311.11
5.2.80.3370.03011.06
5.2.70.0030.06311.10
5.2.60.0070.06010.92
5.2.50.0000.04011.08
5.2.40.1900.02011.00
5.2.30.2970.02710.97
5.2.20.2400.02310.96
5.2.10.2600.03310.91
5.2.00.3070.02710.59
5.1.60.2970.02310.00
5.1.50.2830.0309.96
5.1.40.2770.0239.88
5.1.30.2900.03010.48
5.1.20.2970.03010.37
5.1.10.2600.03010.03
5.1.00.2770.03010.04
5.0.50.1700.0208.46
5.0.40.1400.0208.56
5.0.30.1100.0338.19
5.0.20.1530.0208.25
5.0.10.1470.0208.32
5.0.00.1430.0338.14
4.4.90.0000.0375.78
4.4.80.0000.0275.88
4.4.70.1030.0135.83
4.4.60.1470.0175.85
4.4.50.1270.0175.78
4.4.40.1670.0205.77
4.4.30.1400.0135.77
4.4.20.1470.0135.89
4.4.10.1630.0135.99
4.4.00.1530.0275.93
4.3.110.1400.0135.82
4.3.100.1630.0175.73
4.3.90.1470.0175.79
4.3.80.1570.0275.81
4.3.70.1800.0135.72
4.3.60.1400.0135.75
4.3.50.1700.0175.75
4.3.40.1470.0205.70
4.3.30.0700.0134.72
4.3.20.0870.0234.72
4.3.10.0900.0234.72
4.3.00.0900.0234.72

preferences:
137.02 ms | 1394 KiB | 7 Q