3v4l.org

run code in 300+ PHP versions simultaneously
<?php $contents = <<<EOL console.log('hello'); //# sourceMappingURL= EOL; $backtrack_limit = (int) ini_get('pcre.backtrack_limit'); // Actual limit seems to be this value divided by 2. $backtrack_limit = ($backtrack_limit / 2) - 1; $contents .= str_repeat('x', $backtrack_limit); // Add an empty space after the sourcemap, followed by other code. $contents .= <<<EOL // I appear after the sourcemap. var newcode = 123; EOL; $results = [ 'orig' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*(\S*?)\s*$/m', '', $contents), 'proposed' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*[^$\s]*\s*$/m', '', $contents), 'alt1' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=.*\s*$/m', '', $contents), 'alt2' => preg_replace('/\/\/(#|@)\s(sourceURL|sourceMappingURL)=\s*[^$\s]*/m', '', $contents), // Most efficient so far based off https://regex101.com - (https://stackoverflow.com/a/36629670). 'alt3' => preg_replace('~//[#@]\s(source(?:Mapping)?URL)=\s*(\S+)~', '', $contents), ]; foreach ($results as $key => $result) { echo "------------------------------------------\n"; echo "Results for '$key':\n"; var_dump($result); }

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.10.0110.01518.90
8.5.00.0190.02521.17
8.4.150.0070.01417.45
8.4.140.0160.01519.04
8.4.130.0140.01418.69
8.4.120.0150.01325.03
8.4.110.0130.01619.95
8.4.100.0100.01719.88
8.4.90.0100.01722.02
8.4.80.0070.01619.83
8.4.70.0100.02019.90
8.4.60.0120.01919.84
8.4.50.0120.01919.52
8.4.40.0060.00918.76
8.4.30.0150.00720.02
8.4.20.0160.01020.60
8.4.10.0060.00619.71
8.3.280.0020.00114.05
8.3.270.0100.01817.61
8.3.260.0150.01217.66
8.3.250.0170.01017.79
8.3.240.0120.01418.45
8.3.230.0140.01217.88
8.3.220.0070.00520.04
8.3.210.0130.01317.85
8.3.200.0050.00717.76
8.3.190.0140.01218.07
8.3.180.0070.00519.82
8.3.170.0100.01717.48
8.3.160.0170.01318.23
8.3.150.0060.00618.50
8.3.140.0100.01419.91
8.3.130.0130.00617.84
8.3.120.0060.00619.91
8.3.110.0030.00920.94
8.3.100.0030.01024.06
8.3.90.0030.00926.77
8.3.80.0090.00619.36
8.3.70.0070.02417.75
8.3.60.0040.02917.75
8.3.50.0170.01017.88
8.3.40.0130.00920.30
8.3.30.0130.01020.05
8.3.20.0060.00624.18
8.3.10.0040.00724.66
8.3.00.0070.01026.16
8.2.290.0040.00821.49
8.2.280.0120.01619.52
8.2.270.0110.01818.02
8.2.260.0070.02117.75
8.2.250.0040.00818.76
8.2.240.0100.00318.48
8.2.230.0030.00922.58
8.2.220.0030.01037.54
8.2.210.0060.00626.77
8.2.200.0030.01018.88
8.2.190.0140.01817.50
8.2.180.0040.01825.92
8.2.170.0140.01720.17
8.2.160.0120.00922.96
8.2.150.0060.00625.66
8.2.140.0030.00924.66
8.2.130.0070.00426.16
8.2.120.0060.00621.07
8.2.110.0060.00621.45
8.2.100.0040.01219.03
8.2.90.0080.00418.84
8.2.80.0030.00920.03
8.2.70.0070.00718.88
8.2.60.0030.00918.93
8.2.50.0030.01018.88
8.2.40.0040.00919.34
8.2.30.0030.01019.19
8.2.20.0080.00419.14
8.2.10.0040.00820.26
8.2.00.0000.01220.38
8.1.330.0120.01522.91
8.1.320.0120.01720.23
8.1.310.0040.01117.56
8.1.300.0070.01419.71
8.1.290.0000.01330.84
8.1.280.0070.01525.92
8.1.270.0000.01123.99
8.1.260.0100.00626.35
8.1.250.0000.01128.09
8.1.240.0100.01323.87
8.1.230.0060.01222.62
8.1.220.0030.01018.61
8.1.210.0040.00818.77
8.1.200.0070.00718.48
8.1.190.0080.00418.47
8.1.180.0030.01019.14
8.1.170.0030.01019.70
8.1.160.0070.00719.92
8.1.150.0030.00919.95
8.1.140.0030.00919.92
8.1.130.0060.00621.27
8.1.120.0030.01018.61
8.1.110.0090.00418.60
8.1.100.0030.00918.52
8.1.90.0030.00918.48
8.1.80.0030.00918.64
8.1.70.0000.01118.59
8.1.60.0070.00718.68
8.1.50.0030.01018.54
8.1.40.0060.00618.67
8.1.30.0000.01318.82
8.1.20.0070.00718.78
8.1.10.0060.00918.61
8.1.00.0000.01218.62
8.0.300.0000.01218.77
8.0.290.0080.00417.88
8.0.280.0040.00719.47
8.0.270.0030.00919.11
8.0.260.0070.00419.58
8.0.250.0070.00718.09
8.0.240.0000.01218.20
8.0.230.0040.00718.11
8.0.220.0070.00418.16
8.0.210.0040.00818.02
8.0.200.0030.00718.04
8.0.190.0060.00718.08
8.0.180.0040.01118.17
8.0.170.0080.00418.12
8.0.160.0040.00818.20
8.0.150.0030.00917.86
8.0.140.0000.01318.00
8.0.130.0000.01014.55
8.0.120.0040.01117.97
8.0.110.0080.00418.03
8.0.100.0060.00618.18
8.0.90.0040.00918.07
8.0.80.0030.00918.03
8.0.70.0090.00318.14
8.0.60.0060.00618.22
8.0.50.0030.00918.27
8.0.30.0040.00818.14
8.0.20.0000.01318.16
8.0.10.0000.01418.07
8.0.00.0060.00918.36
7.4.330.0040.00415.55
7.4.320.0030.00917.76
7.4.300.0000.01017.79
7.4.290.0030.01017.63
7.4.280.0030.00917.66
7.4.270.0030.00917.89
7.4.260.0080.00314.52
7.4.250.0000.01217.73
7.4.240.0030.00917.88
7.4.230.0040.00817.85
7.4.220.0000.01217.61
7.4.210.0030.01017.76
7.4.200.0030.01017.96
7.4.190.0030.01017.80
7.4.180.0000.01217.52
7.4.160.0030.00917.54
7.4.150.0040.00817.62
7.4.140.0080.00417.90
7.4.130.0080.00417.73
7.4.120.0000.01217.63
7.4.110.0030.01217.83
7.4.100.0030.01017.81
7.4.90.0000.01317.71
7.4.80.0040.00817.82
7.4.70.0030.01017.83
7.4.60.0030.00917.90
7.4.50.0060.00617.65
7.4.40.0030.00917.53
7.4.30.0040.00817.79
7.4.20.0040.00817.67
7.4.10.0040.01217.47
7.4.00.0000.01517.72
7.3.330.0060.00617.52
7.3.320.0000.01014.43
7.3.310.0030.00917.36
7.3.300.0030.00917.44
7.3.290.0060.00617.52
7.3.280.0040.00817.45
7.3.270.0000.01317.57
7.3.260.0040.00817.58
7.3.250.0040.00817.56
7.3.240.0090.00317.55
7.3.230.0130.00017.56
7.3.220.0030.01017.41
7.3.210.0060.00617.30
7.3.200.0070.00617.47
7.3.190.0000.01217.46
7.3.180.0000.01217.32
7.3.170.0060.00617.27
7.3.160.0030.01017.48
7.3.150.0080.00417.44
7.3.140.0030.01017.50
7.3.130.0030.01017.46
7.3.120.0030.00917.49
7.3.110.0060.00617.36
7.3.100.0000.01217.43
7.3.90.0000.01317.63
7.3.80.0030.01017.47
7.3.70.0060.00617.54
7.3.60.0060.00617.44
7.3.50.0070.00717.48
7.3.40.0030.01017.49
7.3.30.0030.00917.56
7.3.20.0000.01218.34
7.3.10.0030.00918.23
7.3.00.0000.01218.34
5.3.290.0080.00012.63

preferences:
39.46 ms | 403 KiB | 5 Q