3v4l.org

run code in 300+ PHP versions simultaneously
<?php if ( ! function_exists( 'str_starts_with' ) ) { function str_starts_with( $haystack, $needle ) { if ( '' === $needle ) { return true; } return 0 === strpos( $haystack, $needle ); } } $string = 'abcdefghijklmnopqrstuvwxyz'; $start = hrtime(true); for ( $i = 0; $i < 1000000; $i++ ) { $result1 = str_starts_with( $string, 'abc' ); $result2 = str_starts_with( $string, 'abd' ); } $end = hrtime(true); $str_starts_with_time = $end - $start; $start = hrtime(true); for ( $i = 0; $i < 1000000; $i++ ) { $result1 = 0 === strpos( $string, 'abc' ); $result2 = 0 === strpos( $string, 'abd' ); } $end = hrtime(true); $strpos_time = $end - $start; echo 'str_starts_with: ' . $str_starts_with_time . PHP_EOL; echo 'strpos: ' . $strpos_time . PHP_EOL; // echo which function is faster if ( $str_starts_with_time < $strpos_time ) { echo 'str_starts_with is faster' . PHP_EOL; } else { echo 'strpos is faster' . 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.4.20.0100.08324.29
8.4.10.0130.07323.95
8.3.150.0130.07917.13
8.3.140.0030.09216.62
8.3.130.0030.09318.25
8.3.120.0000.08418.89
8.3.110.0100.10916.50
8.3.100.0100.07524.06
8.3.90.0070.07726.77
8.3.80.0000.09117.97
8.3.70.0130.14018.31
8.3.60.0070.15418.55
8.3.50.0070.16118.60
8.3.40.0100.13620.21
8.3.30.0100.14618.54
8.3.20.0070.07624.18
8.3.10.0030.08324.66
8.3.00.0030.08426.16
8.2.270.0070.11017.25
8.2.260.0000.08418.14
8.2.250.0100.07416.72
8.2.240.0100.07818.72
8.2.230.0030.08420.94
8.2.220.0070.08637.54
8.2.210.0030.07826.77
8.2.200.0030.11416.38
8.2.190.0100.14916.58
8.2.180.0100.14716.50
8.2.170.0130.15518.96
8.2.160.0130.14522.96
8.2.150.0070.08025.66
8.2.140.0000.08924.66
8.2.130.0100.08126.16
8.2.120.0030.08319.66
8.2.110.0100.14521.61
8.2.100.0100.12219.12
8.2.90.0000.11320.02
8.2.80.0030.12719.00
8.2.70.0100.12019.02
8.2.60.0100.10319.12
8.2.50.0100.12218.99
8.2.40.0090.11418.17
8.2.30.0130.11917.98
8.2.20.0100.12017.98
8.2.10.0110.12018.03
8.2.00.0150.11718.02
8.1.310.0130.08817.99
8.1.300.0030.07918.57
8.1.290.0100.09318.88
8.1.280.0170.12618.45
8.1.270.0150.09619.50
8.1.260.0070.07726.35
8.1.250.0070.07628.09
8.1.240.0050.13920.63
8.1.230.0050.11519.83
8.1.220.0050.11618.21
8.1.210.0070.12819.43
8.1.200.0120.13617.85
8.1.190.0030.11817.89
8.1.180.0080.12418.18
8.1.170.0100.11717.91
8.1.160.0110.12518.02
8.1.150.0140.12117.93
8.1.140.0090.11517.95
8.1.130.0090.12517.93
8.1.120.0130.11017.94
8.1.110.0060.11717.97
8.1.100.0100.12217.95
8.1.90.0140.12117.92
8.1.80.0120.12118.52
8.1.70.0120.12618.05
8.1.60.0050.12718.01
8.1.50.0100.12417.99
8.1.40.0160.12818.06
8.1.30.0070.12917.97
8.1.20.0120.11317.97
8.1.10.0080.13217.95
8.1.00.0100.12217.99
8.0.300.0100.11219.01
8.0.290.0030.12017.26
8.0.280.0120.12117.67
8.0.270.0120.12118.33
8.0.260.0100.12518.29
8.0.250.0100.12117.71
8.0.240.0060.12317.75
8.0.230.0110.11817.74
8.0.220.0100.11517.70
8.0.210.0090.12217.67
8.0.200.0120.11717.68
8.0.190.0060.12617.70
8.0.180.0120.11717.70
8.0.170.0090.12018.02
8.0.160.0100.11617.96
8.0.150.0070.10917.95
8.0.140.0120.11217.98
8.0.130.0040.11817.68
8.0.120.0120.12317.67
8.0.110.0070.11917.75
8.0.100.0080.12617.65
8.0.90.0040.12417.66
8.0.80.0060.12417.67
8.0.70.0070.12317.62
8.0.60.0070.11118.54
8.0.50.0080.12117.95
8.0.30.0100.11518.04
8.0.20.0080.12017.75
8.0.10.0080.11817.69
7.4.290.0250.15226.77

preferences:
28.17 ms | 403 KiB | 5 Q