3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "This is a " . str_repeat("test", 2) . "!\n" . str_repeat("hello", 3) . " and Bye!\n" . "When I sleep, the thought bubble says " . str_repeat("zz", 3) . "."; function str_shrink($string, $needles) { $needles = array_map(function($needle) { return preg_quote($needle, '~'); }, $needles); return preg_replace_callback( '~\b(' . implode('|', $needles) . ')\1+\b~', function($m) { return "[{$m[1]}](" . (strlen($m[0]) / strlen($m[1])) . ")"; }, $string ); } echo str_shrink($string, ['test', 'hello']);

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.130.0070.00818.02
8.4.120.0090.00220.71
8.4.110.0120.00922.39
8.4.100.0110.01017.77
8.4.90.0060.00318.63
8.4.80.0080.01217.98
8.4.70.0110.00917.92
8.4.60.0150.00718.77
8.4.50.0110.01120.49
8.4.40.0170.00318.53
8.4.30.0070.00718.66
8.4.20.0110.01120.43
8.4.10.0190.00319.77
8.3.260.0080.00116.62
8.3.250.0090.01018.84
8.3.240.0090.01116.79
8.3.230.0090.00716.90
8.3.220.0100.00517.39
8.3.210.0080.00116.64
8.3.200.0100.00516.47
8.3.190.0110.00817.14
8.3.180.0100.01116.79
8.3.170.0060.01317.14
8.3.160.0110.00718.18
8.3.150.0130.00618.84
8.3.140.0000.01519.13
8.3.130.0000.00818.57
8.3.120.0060.00318.82
8.3.110.0060.00320.94
8.3.100.0090.00016.71
8.3.90.0070.01126.77
8.3.80.0090.00018.31
8.3.70.0090.00616.86
8.3.60.0120.00318.54
8.3.50.0030.01324.64
8.3.40.0070.00722.17
8.3.30.0060.00918.91
8.3.20.0000.00721.82
8.3.10.0060.00321.92
8.3.00.0090.00022.37
8.2.290.0050.00620.56
8.2.280.0110.00618.87
8.2.270.0130.00617.31
8.2.260.0000.01018.86
8.2.250.0070.00016.86
8.2.240.0060.01018.82
8.2.230.0040.00422.58
8.2.220.0060.00324.06
8.2.210.0060.00326.77
8.2.200.0060.00318.88
8.2.190.0130.00916.58
8.2.180.0070.01416.75
8.2.170.0090.00622.96
8.2.160.0150.00019.18
8.2.150.0030.00624.18
8.2.140.0000.00724.66
8.2.130.0080.00026.16
8.2.120.0000.00826.16
8.2.110.0100.00722.43
8.2.100.0080.00617.97
8.2.90.0040.00417.88
8.2.80.0060.00318.98
8.2.70.0030.00617.93
8.2.60.0000.00818.34
8.2.50.0050.00319.17
8.2.40.0040.00421.31
8.2.30.0000.00719.31
8.2.20.0050.00218.30
8.2.10.0040.00419.28
8.2.00.0030.00619.41
8.1.330.0110.00823.61
8.1.320.0100.01016.39
8.1.310.0000.00816.84
8.1.300.0040.00716.33
8.1.290.0090.00030.84
8.1.280.0100.00625.92
8.1.270.0040.00422.20
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0090.01323.88
8.1.230.0110.00017.70
8.1.220.0040.00417.76
8.1.210.0000.00818.77
8.1.200.0070.00417.35
8.1.190.0000.00817.38
8.1.180.0000.00818.86
8.1.170.0030.00518.76
8.1.160.0060.00319.07
8.1.150.0000.00718.85
8.1.140.0080.00018.91
8.1.130.0000.00720.19
8.1.120.0000.00717.50
8.1.110.0000.00817.53
8.1.100.0040.00417.63
8.1.90.0130.00017.57
8.1.80.0080.00017.65
8.1.70.0040.00417.55
8.1.60.0030.00617.75
8.1.50.0000.00817.58
8.1.40.0040.00417.70
8.1.30.0000.00817.69
8.1.20.0040.00417.74
8.1.10.0000.00817.73
8.1.00.0000.00817.68
8.0.300.0070.00018.77
8.0.290.0050.00216.75
8.0.280.0070.00018.38
8.0.270.0000.00716.86
8.0.260.0060.00321.76
8.0.250.0070.00017.01
8.0.240.0040.00417.14
8.0.230.0040.00417.11
8.0.220.0040.00417.00
8.0.210.0070.00017.09
8.0.200.0040.00417.10
8.0.190.0040.00417.13
8.0.180.0000.00817.06
8.0.170.0110.00017.04
8.0.160.0000.00717.12
8.0.150.0070.00017.09
8.0.140.0000.00716.98
8.0.130.0030.00313.47
8.0.120.0000.00917.05
8.0.110.0040.00417.04
8.0.100.0070.00017.08
8.0.90.0000.00916.89
8.0.80.0100.00717.08
8.0.70.0000.00816.92
8.0.60.0060.00316.93
8.0.50.0070.00016.99
8.0.30.0090.00916.90
8.0.20.0060.01217.54
8.0.10.0040.00417.09
8.0.00.0180.00017.01
7.4.330.0000.00515.55
7.4.320.0060.00016.85
7.4.300.0040.00416.77
7.4.290.0000.00816.84
7.4.280.0040.00416.79
7.4.270.0110.00016.83
7.4.260.0060.00313.51
7.4.250.0040.00416.80
7.4.240.0040.00316.80
7.4.230.0000.00716.81
7.4.220.0040.00316.80
7.4.210.0070.00916.76
7.4.200.0050.00216.70
7.4.130.0130.00916.74
7.4.120.0070.01116.86
7.4.110.0100.01016.54
7.4.100.0100.00716.89
7.4.90.0100.01016.62
7.4.80.0140.00319.39
7.4.70.0100.00716.70
7.4.60.0100.00716.70
7.4.50.0000.01616.76
7.4.40.0070.01016.71
7.4.30.0080.01216.42
7.4.20.0130.01016.36
7.4.10.0110.01116.37
7.4.00.0110.00716.62
7.3.330.0000.00716.22
7.3.320.0000.00613.19
7.3.310.0000.00716.44
7.3.300.0030.00316.44
7.3.290.0100.00716.37
7.3.280.0120.00416.34
7.3.260.0110.01116.76
7.3.230.0110.00516.39
7.3.210.0120.00416.64
7.3.200.0100.00716.69
7.3.190.0110.00716.71
7.3.180.0070.01016.46
7.3.170.0130.00316.68
7.3.160.0140.01415.98
7.3.150.0180.00616.41
7.3.140.0090.01516.34
7.3.130.0190.00616.45
7.3.120.0080.01216.19
7.3.110.0140.01116.25
7.3.100.0190.00616.53
7.3.90.0080.01416.45
7.3.80.0150.00916.34
7.3.70.0120.01316.14
7.3.60.0330.01016.45
7.3.50.0160.00716.14
7.3.40.0150.00616.39
7.3.30.0100.01016.34
7.3.20.0130.01016.23
7.3.10.0240.00016.25
7.3.00.0080.01316.49
7.2.330.0070.01116.77
7.2.320.0100.00716.87
7.2.310.0170.00016.77
7.2.300.0090.00916.93
7.2.290.0130.00916.77
7.2.280.0130.00816.82
7.2.270.0120.01216.49
7.2.260.0190.00616.64
7.2.250.0130.00716.54
7.2.240.0100.01016.49
7.2.230.0220.00316.59
7.2.220.0120.01016.58
7.2.210.0210.00716.36
7.2.200.0130.00916.72
7.2.190.0080.01916.63
7.2.180.0130.01016.50
7.2.170.0240.00016.63
7.2.160.0130.01316.64
7.2.150.0130.01016.60
7.2.140.0120.01216.60
7.2.130.0100.01216.85
7.2.120.0170.01316.68
7.2.110.0220.00916.75
7.2.100.0250.00016.66
7.2.90.0190.00816.71
7.2.80.0130.00816.96
7.2.70.0320.01316.74
7.2.60.0240.00316.78
7.2.50.0300.00016.83
7.2.40.0170.00916.73
7.2.30.0210.00316.95
7.2.20.0170.00916.77
7.2.10.0150.00916.75
7.2.00.0060.01216.84

preferences:
28.41 ms | 403 KiB | 5 Q