3v4l.org

run code in 300+ PHP versions simultaneously
<?php // https://www.mail-archive.com/internals@lists.php.net/msg87079.html function str_begins($a, $b) { return substr_compare($a, $b, 0, strlen($b)) === 0; } function str_ends($a, $b) { return substr_compare($a, $b, -strlen($b)) === 0; } // Let's test edge cases $funcs = array( 'str_begins', 'str_ends', ); $tests = array( // array(array($main, $part), $expected) array(array("foo", "foo"), true), array(array("foo", ""), true), array(array("", "foo"), false), array(array("", ""), true), ); foreach ($funcs as $func) { foreach ($tests as $test) { list($args, $expected) = $test; list($main, $part) = $args; echo $func . '("' . $main . '", "' . $part . '"):' . PHP_EOL; echo " - Expected: "; var_dump($expected); echo " - Actual: "; var_dump($func($main, $part)); echo PHP_EOL; } echo 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)
8.3.60.0130.00618.31
8.3.50.0060.00916.37
8.3.40.0150.00018.85
8.3.30.0140.00018.68
8.3.20.0030.00620.20
8.3.10.0000.00723.70
8.3.00.0090.00019.45
8.2.180.0180.00318.13
8.2.170.0120.00322.96
8.2.160.0090.00619.21
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0060.00319.15
8.2.120.0050.00326.35
8.2.110.0090.00021.06
8.2.100.0080.00317.91
8.2.90.0050.00319.17
8.2.80.0050.00317.97
8.2.70.0000.00917.75
8.2.60.0040.00418.05
8.2.50.0080.00018.10
8.2.40.0000.00720.59
8.2.30.0070.00019.22
8.2.20.0040.00418.06
8.2.10.0050.00318.23
8.2.00.0030.00618.18
8.1.280.0070.00725.92
8.1.270.0070.00022.06
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0070.00417.48
8.1.230.0080.00317.76
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0000.00817.35
8.1.190.0050.00317.22
8.1.180.0080.00018.10
8.1.170.0050.00318.50
8.1.160.0000.00718.96
8.1.150.0040.00418.80
8.1.140.0030.00519.56
8.1.130.0030.00318.84
8.1.120.0030.00517.39
8.1.110.0000.00817.52
8.1.100.0000.00817.52
8.1.90.0000.00817.53
8.1.80.0040.00417.39
8.1.70.0030.00717.53
8.1.60.0000.00817.50
8.1.50.0000.00817.57
8.1.40.0000.01017.40
8.1.30.0050.00317.64
8.1.20.0000.00817.71
8.1.10.0070.00017.59
8.1.00.0040.00417.39
8.0.300.0000.00719.89
8.0.290.0040.00416.63
8.0.280.0070.00018.37
8.0.270.0000.00717.28
8.0.260.0000.00716.85
8.0.250.0000.00716.91
8.0.240.0050.00216.89
8.0.230.0030.00316.97
8.0.220.0000.00816.96
8.0.210.0050.00316.82
8.0.200.0000.00717.04
8.0.190.0030.00617.00
8.0.180.0000.00716.93
8.0.170.0070.00016.93
8.0.160.0030.00316.91
8.0.150.0030.00316.78
8.0.140.0070.00016.90
8.0.130.0030.00313.33
8.0.120.0080.00016.78
8.0.110.0040.00416.96
8.0.100.0040.00416.92
8.0.90.0040.00417.02
8.0.80.0090.00716.92
8.0.70.0040.00416.98
8.0.60.0000.00716.75
8.0.50.0050.00216.95
8.0.30.0130.00817.11
8.0.20.0090.01217.40
8.0.10.0060.00317.16
8.0.00.0140.00317.00
7.4.330.0050.00015.55
7.4.320.0000.00616.63
7.4.300.0040.00416.63
7.4.290.0060.00616.45
7.4.280.0040.00416.47
7.4.270.0000.00716.44
7.4.260.0030.00316.54
7.4.250.0000.00716.63
7.4.240.0070.00016.49
7.4.230.0000.00716.74
7.4.220.0030.02416.66
7.4.210.0110.00316.57
7.4.200.0070.00016.61
7.4.160.0120.00516.47
7.4.150.0070.01117.40
7.4.140.0110.00817.86
7.4.130.0090.00916.52
7.4.120.0130.01016.45
7.4.110.0110.00716.52
7.4.100.0090.00916.58
7.4.90.0090.00916.57
7.4.80.0100.00719.39
7.4.70.0030.01416.59
7.4.60.0060.00916.60
7.4.50.0090.00616.54
7.4.40.0070.01016.38
7.4.30.0030.01316.53
7.4.00.0110.00715.05
7.3.330.0050.00013.22
7.3.320.0030.00413.32
7.3.310.0030.00316.49
7.3.300.0030.00316.26
7.3.290.0060.00716.38
7.3.280.0080.00916.38
7.3.270.0150.00317.40
7.3.260.0050.01216.68
7.3.250.0140.00616.44
7.3.240.0070.01316.55
7.3.230.0110.01416.60
7.3.210.0030.01316.46
7.3.200.0080.00816.68
7.3.190.0130.00616.38
7.3.180.0070.01016.59
7.3.170.0080.00816.55
7.3.160.0100.01016.37
7.3.120.0030.01414.85
7.3.110.0030.00714.79
7.3.100.0070.01014.56
7.3.90.0000.01414.82
7.3.80.0070.01014.93
7.3.70.0000.01114.71
7.3.60.0030.01014.89
7.3.50.0040.00714.57
7.3.40.0090.00614.90
7.3.30.0070.00714.94
7.3.20.0060.00916.75
7.3.10.0050.00516.79
7.3.00.0080.00616.63
7.2.330.0160.00316.73
7.2.320.0190.00416.55
7.2.310.0130.00316.80
7.2.300.0030.01316.52
7.2.290.0120.00616.62
7.2.240.0060.00615.09
7.2.230.0060.00315.23
7.2.220.0030.01015.24
7.2.210.0070.01115.13
7.2.200.0070.00715.04
7.2.190.0070.01015.15
7.2.180.0030.01315.03
7.2.170.0080.00815.12
7.2.160.0110.00315.26
7.2.150.0030.01016.75
7.2.140.0030.01016.72
7.2.130.0080.00716.96
7.2.120.0030.01216.85
7.2.110.0070.00516.90
7.2.100.0040.01116.84
7.2.90.0030.01216.72
7.2.80.0080.00816.84
7.2.70.0100.00716.94
7.2.60.0070.00717.09
7.2.50.0080.00817.05
7.2.40.0040.01016.89
7.2.30.0090.00516.93
7.2.20.0080.00816.93
7.2.10.0060.00916.77
7.2.00.0070.00717.78
7.1.330.0080.00315.55
7.1.320.0070.00715.90
7.1.310.0040.00715.88
7.1.300.0040.01115.74
7.1.290.0060.00315.74
7.1.280.0030.00615.86
7.1.270.0060.00915.90
7.1.260.0070.01015.78
7.1.250.0110.00515.66
7.1.200.0070.00715.80
7.1.100.0070.00417.88
7.1.70.0070.01017.13
7.1.60.0240.01034.84
7.1.50.0210.01534.85
7.1.40.0250.01934.59
7.1.30.0360.01034.65
7.1.20.0300.01634.42
7.1.10.0120.00916.45
7.1.00.0120.00616.48
7.0.200.0070.01216.76
7.0.190.0130.01016.74
7.0.180.0100.01316.23
7.0.170.0060.01616.05
7.0.160.0150.00816.38
7.0.150.0140.00416.43
7.0.140.0140.00416.49
7.0.130.0130.00616.45
7.0.120.0070.01316.58
7.0.110.0100.01216.24
7.0.100.0060.01316.23
7.0.90.0030.01716.27
7.0.80.0060.01116.28
7.0.70.0080.01116.22
7.0.60.0060.01316.16
7.0.50.0060.01316.42
7.0.40.0070.01016.55
7.0.30.0140.00316.53
7.0.20.0040.01316.31
7.0.10.0130.00416.63
7.0.00.0130.01016.15

preferences:
48.29 ms | 401 KiB | 5 Q