3v4l.org

run code in 300+ PHP versions simultaneously
<?php function edit_distance_ond($str1 ,$str2){ $array = array(); $x = 0; $y = 0; $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 = array(); $a[0] = "aaa"; $a[1] = "bbb"; $a[2] = "ccc"; $b = array(); $b[0] = "www"; $b[1] = "bbb"; $b[2] = "qqq"; echo edit_distance_ond($a,$b); ?>

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.70.0090.00616.63
8.3.60.0130.00718.41
8.3.50.0070.00921.90
8.3.40.0140.00718.58
8.3.30.0110.00619.27
8.3.20.0080.00020.37
8.3.10.0080.00023.53
8.3.00.0000.00720.80
8.2.180.0110.01116.50
8.2.170.0150.00322.96
8.2.160.0070.00720.52
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.26
8.2.110.0060.00321.01
8.2.100.0000.01217.47
8.2.90.0030.00619.23
8.2.80.0040.00417.97
8.2.70.0030.00717.63
8.2.60.0000.00818.05
8.2.50.0040.00718.07
8.2.40.0080.00020.07
8.2.30.0070.00018.33
8.2.20.0040.00417.77
8.2.10.0020.00518.00
8.2.00.0040.00419.52
8.1.280.0070.01425.92
8.1.270.0090.00022.21
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0090.00023.86
8.1.230.0040.00820.96
8.1.220.0060.00318.70
8.1.210.0050.00219.01
8.1.200.0000.00817.22
8.1.190.0040.00417.22
8.1.180.0030.00518.10
8.1.170.0000.00918.64
8.1.160.0040.00421.91
8.1.150.0070.00018.72
8.1.140.0030.00617.47
8.1.130.0000.00717.72
8.1.120.0050.00217.52
8.1.110.0040.00417.48
8.1.100.0040.00417.50
8.1.90.0000.00717.50
8.1.80.0000.00817.50
8.1.70.0030.00317.44
8.1.60.0000.01217.62
8.1.50.0000.00817.43
8.1.40.0000.00717.44
8.1.30.0060.00317.65
8.1.20.0000.00717.65
8.1.10.0040.00417.60
8.1.00.0000.00717.44
8.0.300.0000.00819.93
8.0.290.0040.00416.58
8.0.280.0040.00418.34
8.0.270.0070.00017.26
8.0.260.0000.00617.28
8.0.250.0070.00016.91
8.0.240.0030.00317.02
8.0.230.0000.00717.02
8.0.220.0000.00716.82
8.0.210.0030.00316.96
8.0.200.0060.00016.99
8.0.190.0040.00416.88
8.0.180.0000.00716.93
8.0.170.0000.00716.95
8.0.160.0000.00716.79
8.0.150.0040.00416.81
8.0.140.0050.00216.86
8.0.130.0000.00513.38
8.0.120.0000.00816.80
8.0.110.0040.00416.76
8.0.100.0040.00416.96
8.0.90.0040.00416.98
8.0.80.0160.00016.86
8.0.70.0000.00716.98
8.0.60.0050.00216.80
8.0.50.0040.00416.79
8.0.30.0070.01517.21
8.0.20.0100.00917.43
8.0.10.0000.00817.03
8.0.00.0070.01316.84
7.4.330.0060.00015.01
7.4.320.0030.00316.58
7.4.300.0030.00316.60
7.4.290.0000.00716.54
7.4.280.0090.00016.57
7.4.270.0040.00416.66
7.4.260.0000.00716.50
7.4.250.0040.00416.44
7.4.240.0030.00416.52
7.4.230.0000.00716.41
7.4.220.0120.00316.65
7.4.210.0060.01216.52
7.4.200.0030.00316.51
7.4.160.0030.01316.65
7.4.150.0100.01017.40
7.4.140.0100.00817.86
7.4.130.0100.00816.56
7.4.120.0100.01016.52
7.4.110.0120.00616.39
7.4.100.0130.00716.64
7.4.90.0100.00716.53
7.4.80.0070.01019.39
7.4.70.0080.00916.45
7.4.60.0060.00916.70
7.4.50.0000.00916.61
7.4.40.0070.01116.56
7.4.30.0080.00816.64
7.4.10.0070.01115.15
7.4.00.0060.00915.00
7.3.330.0000.00513.34
7.3.320.0060.00013.18
7.3.310.0000.00716.27
7.3.300.0070.00016.39
7.3.290.0030.01516.37
7.3.280.0060.01216.37
7.3.270.0130.00617.40
7.3.260.0120.00616.52
7.3.250.0110.00616.53
7.3.240.0090.00616.69
7.3.230.0060.01016.63
7.3.210.0140.00316.33
7.3.200.0070.01016.36
7.3.190.0160.00616.36
7.3.180.0070.01016.40
7.3.170.0040.01216.32
7.3.160.0080.00816.38
7.3.130.0060.01314.90
7.3.120.0060.01014.76
7.3.110.0030.01615.13
7.3.100.0030.00915.13
7.3.90.0040.01114.96
7.3.80.0000.01214.84
7.3.70.0060.00314.66
7.3.60.0070.01014.86
7.3.50.0090.00614.81
7.3.40.0090.00614.93
7.3.30.0000.01214.97
7.3.20.0110.00316.74
7.3.10.0040.00716.57
7.3.00.0120.00016.52
7.2.330.0070.01016.59
7.2.320.0160.00316.61
7.2.310.0110.01116.66
7.2.300.0070.01116.85
7.2.290.0140.00416.81
7.2.260.0050.01215.33
7.2.250.0070.00714.94
7.2.240.0090.00615.26
7.2.230.0080.00815.04
7.2.220.0040.01515.32
7.2.210.0040.00814.69
7.2.200.0060.01215.06
7.2.190.0100.00614.73
7.2.180.0060.00714.79
7.2.170.0120.00315.13
7.2.160.0070.00715.10
7.2.150.0050.00517.05
7.2.140.0040.01116.77
7.2.130.0110.00617.14
7.2.120.0030.00616.82
7.2.110.0100.00316.78
7.2.100.0070.01016.98
7.2.90.0030.00716.88
7.2.80.0030.01016.86
7.2.70.0110.00317.07
7.2.60.0080.00817.01
7.2.50.0140.00016.97
7.2.40.0040.00716.99
7.2.30.0100.00716.94
7.2.20.0070.01017.04
7.2.10.0100.00316.99
7.2.00.0050.00818.24
7.1.330.0100.00315.88
7.1.320.0070.00715.68
7.1.310.0030.00815.60
7.1.300.0130.00315.82
7.1.290.0070.00715.78
7.1.280.0070.01015.68
7.1.270.0100.00715.86
7.1.260.0030.01416.04
7.1.250.0070.01016.04
7.1.240.0000.01215.87
7.1.230.0030.00615.55
7.1.220.0080.00815.59
7.1.210.0040.01115.98
7.1.200.0080.00515.79
7.1.190.0060.00915.85
7.1.180.0050.00515.99
7.1.170.0070.00715.86
7.1.160.0040.00815.84
7.1.150.0000.01015.77
7.1.140.0090.00615.77
7.1.130.0120.00315.85
7.1.120.0080.00815.79
7.1.110.0070.00715.92
7.1.100.0050.00617.08
7.1.90.0060.01015.79
7.1.80.0000.01215.93
7.1.70.0050.00716.48
7.1.60.0020.01517.63
7.1.50.0080.01116.46
7.1.40.0030.00815.90
7.1.30.0060.00615.85
7.1.20.0080.00615.76
7.1.10.0030.01015.95
7.1.00.0020.04119.20
7.0.330.0100.00715.47
7.0.320.0060.00815.43
7.0.310.0040.00715.50
7.0.300.0100.00415.43
7.0.290.0070.00715.41
7.0.280.0030.00615.42
7.0.270.0100.00315.32
7.0.260.0030.01015.46
7.0.250.0080.00315.40
7.0.240.0060.00615.65
7.0.230.0080.00415.28
7.0.220.0000.00915.60
7.0.210.0000.01315.51
7.0.200.0030.00715.93
7.0.190.0030.00715.40
7.0.180.0030.00515.64
7.0.170.0040.00815.33
7.0.160.0040.01115.22
7.0.150.0060.00615.45
7.0.140.0020.04318.75
7.0.130.0110.00415.37
7.0.120.0070.01015.52
7.0.110.0070.00715.32
7.0.100.0080.03217.57
7.0.90.0040.04717.65
7.0.80.0160.03917.73
7.0.70.0150.03817.68
7.0.60.0080.04817.70
7.0.50.0040.02817.92
7.0.40.0070.03816.84
7.0.30.0080.04416.82
7.0.20.0050.02916.77
7.0.10.0030.04316.89
7.0.00.0100.04316.74
5.6.400.0100.00614.13
5.6.390.0040.01214.49
5.6.380.0040.01114.45
5.6.370.0120.00314.57
5.6.360.0020.01214.45
5.6.350.0100.00314.77
5.6.340.0060.00914.79
5.6.330.0000.00814.47
5.6.320.0040.00714.61
5.6.310.0040.00814.69
5.6.300.0070.00414.28
5.6.290.0080.00814.28
5.6.280.0040.04217.63
5.6.270.0070.00714.60
5.6.260.0000.01414.64
5.6.250.0030.03917.63
5.6.240.0030.02517.56
5.6.230.0100.03817.51
5.6.220.0100.02517.51
5.6.210.0050.04017.55
5.6.200.0130.02517.74
5.6.190.0090.04517.72
5.6.180.0100.02817.84
5.6.170.0030.04517.74
5.6.160.0030.02817.78
5.6.150.0100.03717.90
5.6.140.0060.04617.72
5.6.130.0140.02017.75
5.6.120.0060.04317.84
5.6.110.0080.04217.74
5.6.100.0080.03517.86
5.6.90.0110.02217.78
5.6.80.0020.03517.38
5.6.70.0100.01817.39
5.6.60.0080.02417.34
5.6.50.0080.04217.48
5.6.40.0020.02817.42
5.6.30.0090.03017.46
5.6.20.0020.02717.39
5.6.10.0060.02217.39
5.6.00.0050.02817.20
5.5.380.0050.04117.49
5.5.370.0070.04617.40
5.5.360.0030.04517.31
5.5.350.0080.03817.43
5.5.340.0080.04317.60
5.5.330.0070.04217.70
5.5.320.0100.03617.88
5.5.310.0030.03117.77
5.5.300.0050.02817.64
5.5.290.0110.02517.83
5.5.280.0070.03317.59
5.5.270.0030.03017.73
5.5.260.0100.02517.56
5.5.250.0070.03417.63
5.5.240.0030.02717.42
5.5.230.0110.02717.30
5.5.220.0080.04217.26
5.5.210.0060.02517.24
5.5.200.0050.02517.37
5.5.190.0120.02017.39
5.5.180.0060.04417.31
5.5.170.0040.01114.35
5.5.160.0080.02717.35
5.5.150.0100.02217.29
5.5.140.0050.04617.35
5.5.130.0090.03217.18
5.5.120.0080.04317.17
5.5.110.0030.04617.29
5.5.100.0070.02317.18
5.5.90.0120.03217.29
5.5.80.0030.02817.21
5.5.70.0020.03117.01
5.5.60.0060.04417.31
5.5.50.0100.02117.25
5.5.40.0090.03717.21
5.5.30.0140.03017.25
5.5.20.0030.03917.10
5.5.10.0080.02217.15
5.5.00.0100.01817.09
5.4.450.0030.04415.43
5.4.440.0020.02815.49
5.4.430.0040.02415.43
5.4.420.0070.02215.48
5.4.410.0120.02215.42
5.4.400.0020.02715.33
5.4.390.0100.04015.31
5.4.380.0090.03515.27
5.4.370.0020.03615.27
5.4.360.0090.03315.27
5.4.350.0100.03515.28
5.4.340.0080.03415.27
5.4.330.0000.00611.50
5.4.320.0070.02315.37
5.4.310.0050.02715.36
5.4.300.0030.02415.31
5.4.290.0060.02715.35
5.4.280.0030.02815.31
5.4.270.0060.03215.37
5.4.260.0020.02415.37
5.4.250.0010.04615.26
5.4.240.0080.03515.34
5.4.230.0050.03415.20
5.4.220.0050.04015.31
5.4.210.0100.03815.27
5.4.200.0070.02315.31
5.4.190.0030.02315.31
5.4.180.0070.03115.27
5.4.170.0050.02615.20
5.4.160.0070.04215.32
5.4.150.0070.03815.18
5.4.140.0060.02513.93
5.4.130.0090.03913.94
5.4.120.0050.03213.93
5.4.110.0060.03813.92
5.4.100.0060.04013.94
5.4.90.0050.02113.98
5.4.80.0020.03213.93
5.4.70.0050.02313.98
5.4.60.0070.02013.92
5.4.50.0040.04013.88
5.4.40.0000.03813.96
5.4.30.0040.02213.96
5.4.20.0030.03813.97
5.4.10.0090.03713.93
5.4.00.0080.03113.68
5.3.290.0020.02513.61
5.3.280.0070.03713.61
5.3.270.0030.04313.61
5.3.260.0050.04313.61
5.3.250.0050.03913.61
5.3.240.0080.03813.61
5.3.230.0100.03713.61
5.3.220.0020.04013.61
5.3.210.0060.03313.61
5.3.200.0050.04013.61
5.3.190.0080.04013.61
5.3.180.0050.01713.61
5.3.170.0070.03713.61
5.3.160.0030.02213.61
5.3.150.0030.04013.61
5.3.140.0060.02713.61
5.3.130.0050.03313.61
5.3.120.0070.03213.61
5.3.110.0050.03013.61
5.3.100.0030.02213.61
5.3.90.0050.03013.61
5.3.80.0030.03513.61
5.3.70.0030.03813.61
5.3.60.0050.02813.61
5.3.50.0070.02313.61
5.3.40.0010.03913.61
5.3.30.0020.03313.61
5.3.20.0090.03513.61
5.3.10.0030.03213.61
5.3.00.0080.03313.61
5.2.170.0030.03015.72
5.2.160.0000.03315.72
5.2.150.0070.05015.72
5.2.140.0000.06315.72
5.2.130.0070.05015.72
5.2.120.0030.06315.72
5.2.110.0070.05715.72
5.2.100.0070.05015.72
5.2.90.0070.06015.72
5.2.80.0030.03315.72
5.2.70.0070.06315.72
5.2.60.0000.02715.72
5.2.50.0030.05015.72
5.2.40.0030.04715.72
5.2.30.0030.03315.72
5.2.20.0070.05315.72
5.2.10.0000.02715.72
5.2.00.0070.02715.72
5.1.60.0000.02315.72
5.1.50.0000.04715.72
5.1.40.0000.06315.72
5.1.30.0070.05715.72
5.1.20.0030.06015.72
5.1.10.0030.05715.72
5.1.00.0070.05315.72
5.0.50.0000.05015.72
5.0.40.0030.04715.72
5.0.30.0000.08315.72
5.0.20.0070.03715.72
5.0.10.0030.03715.72
5.0.00.0070.06315.72
4.4.90.0070.03015.72
4.4.80.0000.03315.72
4.4.70.0000.03015.72
4.4.60.0030.01315.72
4.4.50.0000.04015.72
4.4.40.0000.02315.72
4.4.30.0130.01715.72
4.4.20.0030.03715.72
4.4.10.0100.02715.72
4.4.00.0030.02315.72
4.3.110.0000.03715.72
4.3.100.0030.03315.72
4.3.90.0000.01715.72
4.3.80.0030.05015.72
4.3.70.0030.02015.72
4.3.60.0000.02015.72
4.3.50.0030.03015.72
4.3.40.0030.03715.72
4.3.30.0030.03315.72
4.3.20.0030.03015.72
4.3.10.0070.03715.72
4.3.00.0070.02715.72

preferences:
57.65 ms | 401 KiB | 5 Q