3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x = 0; $y = 0; $offset = strlen($str1); $array[$offset + 1] = 0; for($D = 0; $D <= strlen($str1) + strlen($str2); $D++){ echo $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 < strlen($str1) && $y < strlen($str2) && $str1[$x] == $str2[$y]){ $x++; $y++; } $array[$k+$offset] = $x; if($x >= strlen($str1) && $y >= strlen($str2)) return $D; } } return -1; } $a = "test"; $b = "test2"; $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.0140.00716.73
8.3.50.0140.00322.12
8.3.40.0070.00718.92
8.3.30.0110.00419.08
8.3.20.0040.00420.29
8.3.10.0050.00223.53
8.3.00.0040.00419.26
8.2.180.0090.00618.33
8.2.170.0070.00722.96
8.2.160.0070.01020.57
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0090.00626.16
8.2.120.0000.00722.25
8.2.110.0180.00422.07
8.2.100.0030.01117.78
8.2.90.0000.00819.17
8.2.80.0000.00817.97
8.2.70.0060.00317.61
8.2.60.0000.00818.03
8.2.50.0060.00318.07
8.2.40.0040.00418.09
8.2.30.0000.00718.24
8.2.20.0000.00717.64
8.2.10.0000.00718.01
8.2.00.0070.00317.71
8.1.280.0110.00425.92
8.1.270.0130.00322.19
8.1.260.0000.00726.35
8.1.250.0050.00328.09
8.1.240.0060.00323.82
8.1.230.0070.00419.01
8.1.220.0000.00817.74
8.1.210.0070.00318.77
8.1.200.0100.00017.35
8.1.190.0060.00317.54
8.1.180.0030.00618.10
8.1.170.0060.00318.55
8.1.160.0000.00722.07
8.1.150.0030.00518.66
8.1.140.0000.00717.37
8.1.130.0080.00017.90
8.1.120.0000.00717.39
8.1.110.0040.00417.36
8.1.100.0070.00017.47
8.1.90.0040.00417.55
8.1.80.0000.00717.46
8.1.70.0000.00717.41
8.1.60.0030.00617.50
8.1.50.0040.00417.49
8.1.40.0030.00617.59
8.1.30.0040.00417.60
8.1.20.0040.00417.58
8.1.10.0050.00317.57
8.1.00.0030.00517.41
8.0.300.0070.00019.09
8.0.290.0000.00717.05
8.0.280.0030.00318.38
8.0.270.0000.00817.29
8.0.260.0000.00717.23
8.0.250.0000.00716.98
8.0.240.0080.00016.96
8.0.230.0000.00717.01
8.0.220.0000.00716.88
8.0.210.0000.00716.78
8.0.200.0030.00317.00
8.0.190.0040.00416.90
8.0.180.0040.00416.81
8.0.170.0000.00817.02
8.0.160.0040.00416.90
8.0.150.0030.00316.76
8.0.140.0040.00416.84
8.0.130.0030.00313.39
8.0.120.0000.00816.86
8.0.110.0040.00416.89
8.0.100.0000.00716.79
8.0.90.0030.00416.78
8.0.80.0110.00316.86
8.0.70.0000.00716.87
8.0.60.0000.00816.86
8.0.50.0040.00416.86
8.0.30.0050.01416.94
8.0.20.0100.00817.40
8.0.10.0030.00616.82
8.0.00.0080.00816.80
7.4.330.0020.00215.00
7.4.320.0000.00616.54
7.4.300.0030.00616.52
7.4.290.0000.00816.49
7.4.280.0040.00416.59
7.4.270.0000.00716.52
7.4.260.0070.00316.58
7.4.250.0040.00416.54
7.4.240.0030.00416.52
7.4.230.0000.00716.70
7.4.220.0060.01016.69
7.4.210.0070.00816.49
7.4.200.0030.00316.27
7.4.190.0000.00716.70
7.4.160.0120.00316.55
7.4.150.0130.00717.40
7.4.140.0110.00617.86
7.4.130.0100.00716.48
7.4.120.0070.01016.42
7.4.110.0110.00716.70
7.4.100.0140.00716.57
7.4.90.0090.00916.57
7.4.80.0060.01219.39
7.4.70.0040.01216.55
7.4.60.0120.00816.34
7.4.50.0000.00816.41
7.4.40.0030.01222.77
7.4.30.0130.00316.61
7.4.00.0000.01214.83
7.3.330.0060.00013.36
7.3.320.0030.00313.19
7.3.310.0000.00716.39
7.3.300.0030.00316.41
7.3.290.0030.01016.38
7.3.280.0060.01216.39
7.3.270.0070.01017.40
7.3.260.0080.00816.42
7.3.250.0120.00516.47
7.3.240.0060.01316.69
7.3.230.0120.00816.39
7.3.210.0100.00716.65
7.3.200.0120.00619.39
7.3.190.0120.00616.40
7.3.180.0110.00616.70
7.3.170.0100.00616.72
7.3.160.0160.00416.52
7.3.120.0090.00615.03
7.2.330.0030.01416.70
7.2.320.0120.00616.55
7.2.310.0100.00716.58
7.2.300.0060.00916.50
7.2.290.0090.00616.71
7.2.00.0000.01519.20
7.1.100.0030.00618.09
7.1.70.0000.00717.02
7.1.60.0110.01419.33
7.1.50.0070.01417.10
7.1.00.0070.07322.57
7.0.200.0030.00616.76
7.0.140.0070.07021.93
7.0.60.0000.08719.90
7.0.50.0030.07717.88
7.0.40.0100.06720.13
7.0.30.0470.07720.13
7.0.20.0270.08020.19
7.0.10.0070.08020.07
7.0.00.0230.06720.18
5.6.280.0030.07320.83
5.6.210.0130.07720.62
5.6.200.0100.05018.21
5.6.190.0000.05320.47
5.6.180.0400.07320.61
5.6.170.0230.05020.50
5.6.160.0030.09320.53
5.6.150.0030.04318.23
5.6.140.0130.07718.19
5.6.130.0000.09318.18
5.6.120.0030.05321.15
5.6.110.0200.07721.14
5.6.100.0030.07320.98
5.6.90.0000.07721.13
5.6.80.0100.07720.55
5.6.70.5130.04020.45
5.5.350.0070.03720.48
5.5.340.0130.07018.07
5.5.330.0030.06020.47
5.5.320.0100.07720.30
5.5.310.0100.04720.37
5.5.300.0100.03317.93
5.5.290.0030.05017.98
5.5.280.0000.07320.71
5.5.270.0000.07720.77
5.5.260.0030.04020.78
5.5.250.0030.04020.63
5.5.240.0170.08320.20
5.4.450.0870.06319.48
5.4.440.0770.05019.38
5.4.430.0730.05319.60
5.4.420.0530.05719.30
5.4.410.0600.06019.35
5.4.400.0800.05319.31
5.4.390.0830.04019.14
5.4.380.0100.07718.77
5.4.370.0200.06718.79
5.4.360.0200.05718.48
5.4.350.0200.05718.57
5.4.340.0200.05018.79
5.4.320.0050.03712.52
5.4.310.0080.04112.51
5.4.300.0090.03712.51
5.4.290.0050.03912.51
5.4.280.0050.04612.38
5.4.270.0080.03512.38
5.4.260.0050.04912.38
5.4.250.0100.04612.38
5.4.240.0070.03712.38
5.4.230.0080.03912.37
5.4.220.0080.05312.37
5.4.210.0120.03612.37
5.4.200.0100.03912.37
5.4.190.0060.03612.37
5.4.180.0090.03312.37
5.4.170.0080.04212.38
5.4.160.0080.03612.37
5.4.150.0070.03612.37
5.4.140.0080.03612.05
5.4.130.0080.03512.04
5.4.120.0090.03912.00
5.4.110.0090.05311.99
5.4.100.0070.04412.00
5.4.90.0080.03912.00
5.4.80.0090.03611.99
5.4.70.0080.03411.99
5.4.60.0090.04311.99
5.4.50.0100.03711.99
5.4.40.0070.03411.98
5.4.30.0070.03511.97
5.4.20.0100.03411.98
5.4.10.0080.03611.98
5.4.00.0050.04211.46
5.3.290.0060.04012.80
5.3.280.0050.04012.71
5.3.270.0080.04012.73
5.3.260.0130.05012.72
5.3.250.0120.04212.72
5.3.240.0080.03612.71
5.3.230.0060.04012.71
5.3.220.0090.04212.68
5.3.210.0060.06012.68
5.3.200.0070.05512.68
5.3.190.0060.04112.68
5.3.180.0110.04612.67
5.3.170.0080.05412.67
5.3.160.0140.05212.67
5.3.150.0080.04812.67
5.3.140.0040.05012.66
5.3.130.0060.03912.66
5.3.120.0100.04412.66
5.3.110.0050.04012.66
5.3.100.0080.03612.12
5.3.90.0090.03612.09
5.3.80.0080.03612.07
5.3.70.0110.03912.07
5.3.60.0090.05212.06
5.3.50.0090.05212.01
5.3.40.0090.04712.01
5.3.30.0100.04611.96
5.3.20.0140.04011.75
5.3.10.0100.04711.71
5.3.00.0090.06411.71
5.2.170.0080.0509.20
5.2.160.0070.0529.20
5.2.150.0120.0539.20
5.2.140.0080.0489.19
5.2.130.0100.0349.16
5.2.120.0040.0429.16
5.2.110.0090.0419.17
5.2.100.0070.0429.16
5.2.90.0070.0569.16
5.2.80.0070.0489.16
5.2.70.0110.0459.16
5.2.60.0030.0389.11
5.2.50.0060.0479.09
5.2.40.0140.0369.05
5.2.30.0090.0469.04
5.2.20.0100.0469.02
5.2.10.0090.0398.93
5.2.00.0090.0438.80
5.1.60.0060.0398.08
5.1.50.0070.0388.09
5.1.40.0060.0458.07
5.1.30.0090.0418.41
5.1.20.0080.0458.44
5.1.10.0090.0378.16
5.1.00.0030.0338.16
5.0.50.0050.0296.64
5.0.40.0050.0206.51
5.0.30.0040.0386.31
5.0.20.0060.0306.29
5.0.10.0060.0316.27
5.0.00.0070.0386.26
4.4.90.0080.0224.78
4.4.80.0060.0254.75
4.4.70.0020.0254.75
4.4.60.0030.0204.76
4.4.50.0040.0214.77
4.4.40.0050.0304.71
4.4.30.0030.0184.76
4.4.20.0050.0224.84
4.4.10.0030.0234.85
4.4.00.0050.0354.76
4.3.110.0080.0194.67
4.3.100.0050.0154.67
4.3.90.0030.0164.64
4.3.80.0060.0224.58
4.3.70.0050.0134.63
4.3.60.0020.0164.63
4.3.50.0030.0174.63
4.3.40.0040.0344.54
4.3.30.0030.0233.32
4.3.20.0050.0193.30
4.3.10.0050.0133.26
4.3.00.0170.02010.37

preferences:
36.25 ms | 401 KiB | 5 Q