3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x; $y; $offset = count($str1); $array[$offset + 1] = 0; for($D = 0; $D <= count($str1) + count($str2); $D++){ for($k = -$D; $k <= $D; $k += 2){ if($k == -$D || $k != $D && $array[$k-1+$offset] < $array[$k+1+$offset]) $x = $array[$k+1+$offset]; else $x = $array[$k-1+$offset] + 1; $y = $x - $k; while($x < count($str1) && $y < count($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= count($str1) && $y >= count($str2)) return $D; } } return -1; } $a = "test"; $b = "ttst2"; $edo = edit_distance_ond($a,$b); echo $edo; ?>

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.0070.01016.50
8.3.50.0070.01022.10
8.3.40.0120.00318.84
8.3.30.0140.00019.05
8.3.20.0040.00420.33
8.3.10.0080.00023.56
8.3.00.0040.00419.13
8.2.180.0100.01018.29
8.2.170.0110.00722.96
8.2.160.0100.00320.53
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00422.25
8.2.110.0040.00422.20
8.2.100.0040.00817.78
8.2.90.0040.00419.23
8.2.80.0000.00917.97
8.2.70.0100.00017.63
8.2.60.0000.00817.80
8.2.50.0050.00318.07
8.2.40.0000.00718.22
8.2.30.0070.00018.04
8.2.20.0040.00417.69
8.2.10.0020.00518.21
8.2.00.0050.00517.65
8.1.280.0070.01025.92
8.1.270.0050.00322.19
8.1.260.0030.00626.35
8.1.250.0070.00028.09
8.1.240.0090.00023.96
8.1.230.0110.00019.15
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0060.00317.25
8.1.190.0040.00417.63
8.1.180.0080.00018.10
8.1.170.0090.00018.64
8.1.160.0040.00422.01
8.1.150.0080.00018.58
8.1.140.0050.00317.53
8.1.130.0030.00317.79
8.1.120.0040.00417.56
8.1.110.0040.00417.51
8.1.100.0000.00717.39
8.1.90.0040.00417.49
8.1.80.0070.00017.52
8.1.70.0000.00717.44
8.1.60.0060.00317.63
8.1.50.0000.00817.55
8.1.40.0040.00417.45
8.1.30.0040.00417.60
8.1.20.0040.00417.69
8.1.10.0040.00417.61
8.1.00.0000.00717.52
8.0.300.0000.00820.86
8.0.290.0080.00017.18
8.0.280.0070.00018.47
8.0.270.0030.00317.16
8.0.260.0000.00617.19
8.0.250.0070.00016.90
8.0.240.0000.00716.88
8.0.230.0040.00417.02
8.0.220.0000.00716.82
8.0.210.0090.00016.83
8.0.200.0000.00616.98
8.0.190.0000.00816.95
8.0.180.0040.00416.95
8.0.170.0040.00416.99
8.0.160.0000.00717.04
8.0.150.0070.00016.81
8.0.140.0000.00716.93
8.0.130.0060.00013.42
8.0.120.0000.00816.95
8.0.110.0040.00416.91
8.0.100.0000.00717.00
8.0.90.0050.00217.05
8.0.80.0110.00317.08
8.0.70.0040.00417.03
8.0.60.0030.00516.86
8.0.50.0080.00016.94
8.0.30.0130.00717.09
8.0.20.0080.01217.40
8.0.10.0050.00316.87
8.0.00.0150.00316.74
7.4.330.0050.00015.00
7.4.320.0020.00516.52
7.4.300.0030.00316.54
7.4.290.0000.00716.63
7.4.280.0080.00016.41
7.4.270.0040.00416.64
7.4.260.0000.01016.44
7.4.250.0070.00016.50
7.4.240.0020.00516.52
7.4.230.0030.00316.70
7.4.220.0140.00316.63
7.4.210.0090.01116.62
7.4.200.0030.00316.43
7.4.190.0040.00416.72
7.4.160.0150.00016.57
7.4.150.0170.00717.40
7.4.140.0030.01517.86
7.4.130.0070.01316.56
7.4.120.0060.01216.60
7.4.110.0140.00316.46
7.4.100.0030.01416.33
7.4.90.0130.00316.48
7.4.80.0130.00319.39
7.4.70.0110.00616.61
7.4.60.0110.00716.50
7.4.50.0040.00416.48
7.4.40.0030.01422.77
7.4.30.0000.01716.71
7.4.00.0070.01014.96
7.3.330.0050.00013.48
7.3.320.0040.00413.52
7.3.310.0000.00716.30
7.3.300.0000.00716.46
7.3.290.0060.00916.46
7.3.280.0080.00716.44
7.3.270.0110.00717.40
7.3.260.0060.01616.57
7.3.250.0100.00716.55
7.3.240.0120.00616.50
7.3.230.0120.00616.64
7.3.210.0000.01716.38
7.3.200.0110.01119.39
7.3.190.0150.00916.45
7.3.180.0060.00916.53
7.3.170.0090.01216.51
7.3.160.0090.01316.64
7.3.120.0110.00414.98
7.2.330.0120.00916.88
7.2.320.0080.01116.70
7.2.310.0030.01516.52
7.2.300.0030.01716.46
7.2.290.0080.00816.57
7.2.80.0090.00616.43
7.2.60.0090.00616.68
7.2.00.0060.00919.27
7.1.200.0090.00315.43
7.1.100.0030.00717.96
7.1.70.0060.01316.81
7.1.60.0090.01519.33
7.1.50.0120.00917.06
7.1.00.0070.07322.31
7.0.200.0040.00416.64
7.0.140.0030.07322.11
7.0.60.0100.07319.94
7.0.50.0030.07317.87
7.0.40.0030.08320.09
7.0.30.0200.07020.24
7.0.20.0230.03720.23
7.0.10.0100.07320.19
7.0.00.0100.08720.33
5.6.280.0030.07020.96
5.6.210.0070.08720.52
5.6.200.0070.07318.16
5.6.190.0100.03720.47
5.6.180.0370.07020.66
5.6.170.0230.04320.44
5.6.160.0170.07320.57
5.6.150.0070.08318.15
5.6.140.0130.06718.21
5.6.130.0130.07318.11
5.6.120.0130.08021.14
5.6.110.0130.07320.97
5.6.100.0000.04720.96
5.6.90.0100.08321.04
5.6.80.0130.07720.38
5.6.70.3430.05020.36
5.5.350.0200.05320.42
5.5.340.0130.08017.98
5.5.330.0130.07020.35
5.5.320.0030.07720.35
5.5.310.0200.03320.27
5.5.300.0030.08018.08
5.5.290.0130.08017.94
5.5.280.0070.06320.85
5.5.270.0070.08720.90
5.5.260.0000.04320.79
5.5.250.0000.04320.69
5.5.240.0230.06020.28
5.4.450.2300.03019.41
5.4.440.2900.03719.46
5.4.430.3630.04319.27
5.4.420.3530.04019.63
5.4.410.3570.03319.09
5.4.400.3370.04319.14
5.4.390.2900.03719.36
5.4.380.2830.04019.22
5.4.370.0470.06018.83
5.4.360.0330.07019.22
5.4.350.0230.05019.20
5.4.340.0300.08019.09
5.4.320.0400.06319.09
5.4.310.0330.06719.31
5.4.300.0430.05718.94
5.4.290.0270.05719.13
5.4.280.0370.05319.25
5.4.270.0270.03719.21
5.4.260.0330.04319.16
5.4.250.0230.05718.84
5.4.240.0270.05718.84
5.4.230.0400.06718.86
5.4.220.0230.04019.23
5.4.210.0300.06319.14
5.4.200.0330.06718.99
5.4.190.0300.07019.08
5.4.180.0300.04019.06
5.4.170.0270.04719.30
5.4.160.0300.03019.16
5.4.150.0230.05719.13
5.4.140.0270.03716.34
5.4.130.0230.07016.32
5.4.120.0300.07016.48
5.4.110.0270.03716.46
5.4.100.0230.06716.19
5.4.90.0270.07016.27
5.4.80.0370.06016.54
5.4.70.0270.07316.50
5.4.60.0400.05716.52
5.4.50.0370.04716.53
5.4.40.0300.06716.53
5.4.30.0330.04016.42
5.4.20.0300.04016.53
5.4.10.0200.04016.53
5.4.00.0370.06015.75
5.3.290.0300.03314.56
5.3.280.0370.07014.63
5.3.270.0270.04314.67
5.3.260.0270.05714.61
5.3.250.0230.07314.70
5.3.240.0270.05714.69
5.3.230.0300.04314.72
5.3.220.0300.07314.57
5.3.210.0300.06714.48
5.3.200.0230.04014.65
5.3.190.0370.07314.66
5.3.180.0300.07014.47
5.3.170.0300.07714.54
5.3.160.0230.07014.58
5.3.150.0370.07014.57
5.3.140.0370.06314.48
5.3.130.0370.06014.48
5.3.120.0270.03714.55
5.3.110.0270.07714.58
5.3.100.0330.04314.02
5.3.90.0370.06013.95
5.3.80.0300.07014.25
5.3.70.0230.07714.01
5.3.60.0330.06714.10
5.3.50.0300.04014.07
5.3.40.0370.05713.89
5.3.30.0300.05714.04
5.3.20.0330.04013.78
5.3.10.0400.06013.82
5.3.00.0300.05713.58
5.2.170.0270.05311.06
5.2.160.0230.06011.07
5.2.150.0270.03711.32
5.2.140.0270.03311.07
5.2.130.0330.05311.02
5.2.120.0300.05311.04
5.2.110.0130.04311.21
5.2.100.0370.05011.19
5.2.90.0200.06011.16
5.2.80.0200.03711.27
5.2.70.0200.04011.08
5.2.60.0200.03710.97
5.2.50.0130.03011.11
5.2.40.0070.03310.92
5.2.30.0170.03010.91
5.2.20.0170.02310.88
5.2.10.0070.04710.99
5.2.00.0200.03310.78
5.1.60.0130.04710.16
5.1.50.0200.04310.13
5.1.40.0230.05010.12
5.1.30.0270.02710.36
5.1.20.0200.03010.59
5.1.10.0370.03710.08
5.1.00.0930.04010.09
5.0.50.0530.02010.11
5.0.40.0370.02010.14
5.0.30.0130.06010.17
5.0.20.0130.04310.18
5.0.10.0100.04010.18
5.0.00.0100.03010.19
4.4.90.0070.0379.98
4.4.80.0100.01710.00
4.4.70.0030.01710.04
4.4.60.0100.01710.04
4.4.50.0070.01310.05
4.4.40.0130.04310.07
4.4.30.0030.02310.07
4.4.20.0100.01010.08
4.4.10.0070.02010.10
4.4.00.0200.04310.12
4.3.110.0200.03310.16
4.3.100.0130.03310.17
4.3.90.0130.03010.18
4.3.80.0070.02710.20
4.3.70.0130.03310.20
4.3.60.0130.03310.20
4.3.50.0130.01710.20
4.3.40.0070.04310.20
4.3.30.0070.03710.21
4.3.20.0070.02010.21
4.3.10.0030.03710.22
4.3.00.0030.03710.23

preferences:
41.38 ms | 401 KiB | 5 Q