3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.2.60.0030.01316.96
7.2.00.0030.01219.38
7.1.200.0090.00615.88
7.1.100.0030.00618.19
7.1.70.0030.00617.09
7.1.60.0040.01819.70
7.1.50.0080.01517.09
7.1.00.0000.07722.44
7.0.200.0000.00816.52
7.0.140.0000.07722.00
7.0.100.0030.06320.07
7.0.90.0030.08719.92
7.0.80.0270.07019.95
7.0.70.0270.06319.93
7.0.60.0130.09019.96
7.0.50.0000.05020.34
7.0.40.0100.07020.19
7.0.30.0100.08020.14
7.0.20.0070.04720.08
7.0.10.0070.07720.13
7.0.00.0130.08020.12
5.6.280.0030.07320.93
5.6.250.0070.06320.49
5.6.240.0030.04320.68
5.6.230.0130.07020.60
5.6.220.0130.04020.63
5.6.210.0030.07320.78
5.6.200.0230.04021.05
5.6.190.0070.08721.04
5.6.180.0170.04321.07
5.6.170.0070.08021.04
5.6.160.0030.04721.02
5.6.150.0130.07020.96
5.6.140.0070.08321.05
5.6.130.0200.03321.14
5.6.120.0070.08021.18
5.6.110.0070.07321.11
5.6.100.0070.06321.03
5.6.90.0130.03721.08
5.6.80.0030.05720.43
5.6.70.0100.03720.50
5.6.60.0170.03320.34
5.6.50.0100.08020.56
5.6.40.0030.04720.39
5.6.30.0070.05720.50
5.6.20.0030.04720.39
5.6.10.0030.04020.47
5.6.00.0030.04720.30
5.5.380.0100.07020.41
5.5.370.0130.08020.36
5.5.360.0000.08720.54
5.5.350.0130.07020.38
5.5.340.0070.08020.89
5.5.330.0100.07720.93
5.5.320.0130.06720.94
5.5.310.0030.05720.91
5.5.300.0070.04720.91
5.5.290.0100.04720.88
5.5.280.0030.05720.81
5.5.270.0030.04720.84
5.5.260.0070.04720.83
5.5.250.0130.05320.62
5.5.240.0030.04320.25
5.5.230.0100.05020.25
5.5.220.0070.08020.29
5.5.210.0070.04320.31
5.5.200.0030.04320.26
5.5.190.0130.04020.29
5.5.180.0100.08320.25
5.5.160.0070.05020.29
5.5.150.0100.04020.15
5.5.140.0070.08320.19
5.5.130.0100.06320.25
5.5.120.0070.08020.18
5.5.110.0030.08020.16
5.5.100.0070.04020.03
5.5.90.0170.06020.08
5.5.80.0000.04720.17
5.5.70.0030.05319.93
5.5.60.0070.07720.15
5.5.50.0130.03320.13
5.5.40.0100.06720.15
5.5.30.0200.05719.93
5.5.20.0070.06320.04
5.5.10.0100.03720.07
5.5.00.0100.03320.09
5.4.450.0030.08319.36
5.4.440.0030.04719.49
5.4.430.0030.04319.36
5.4.420.0100.04019.47
5.4.410.0200.04019.33
5.4.400.0030.04319.16
5.4.390.0100.07719.13
5.4.380.0130.06719.05
5.4.370.0000.06319.04
5.4.360.0100.06319.05
5.4.350.0130.06719.05
5.4.340.0170.06019.05
5.4.320.0070.04319.23
5.4.310.0070.04319.21
5.4.300.0030.04319.12
5.4.290.0000.05319.20
5.4.280.0030.05019.13
5.4.270.0070.06019.25
5.4.260.0000.04019.23
5.4.250.0000.08719.02
5.4.240.0070.06719.17
5.4.230.0100.06018.89
5.4.220.0070.07319.13
5.4.210.0130.06719.04
5.4.200.0070.03719.11
5.4.190.0000.04019.12
5.4.180.0100.05319.04
5.4.170.0070.04318.89
5.4.160.0100.07719.14
5.4.150.0100.07318.86
5.4.140.0070.04316.35
5.4.130.0130.07016.39
5.4.120.0070.05716.36
5.4.110.0070.07016.34
5.4.100.0070.07316.38
5.4.90.0030.03716.47
5.4.80.0000.05716.36
5.4.70.0030.04316.46
5.4.60.0100.03016.34
5.4.50.0030.07716.25
5.4.40.0000.06316.42
5.4.30.0000.04016.41
5.4.20.0030.07316.43
5.4.10.0100.07016.36
5.4.00.0100.06015.86
5.3.290.0030.04315.72
5.3.280.0070.07015.72
5.3.270.0030.07715.72
5.3.260.0000.08315.72
5.3.250.0100.07315.72
5.3.240.0130.07015.72
5.3.230.0100.07315.72
5.3.220.0030.07315.72
5.3.210.0070.06315.72
5.3.200.0030.07315.72
5.3.190.0100.07315.72
5.3.180.0030.03315.72
5.3.170.0100.06715.72
5.3.160.0000.04315.72
5.3.150.0030.07015.72
5.3.140.0070.05015.72
5.3.130.0070.05715.72
5.3.120.0100.05715.72
5.3.110.0070.05715.72
5.3.100.0070.03315.72
5.3.90.0030.05715.72
5.3.80.0070.06315.72
5.3.70.0070.07015.72
5.3.60.0100.05015.72
5.3.50.0070.04715.72
5.3.40.0000.07315.72
5.3.30.0030.06015.72
5.3.20.0100.07015.72
5.3.10.0030.05715.72
5.3.00.0130.05715.72
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