Levenshtein Distance





Methodology

Timings taken via hyperfine on an M3 Macbook pro with 16 gb RAM.


Hyperfine output

Benchmarking Java
Benchmark 1: java jvm/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      77.8 ms ±   1.5 ms    [User: 57.9 ms, System: 21.3 ms]
  Range (min … max):    76.0 ms …  80.4 ms    7 runs


Benchmarking Go
Benchmark 1:  ./go/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      31.5 ms ±   2.9 ms    [User: 17.1 ms, System: 2.9 ms]
  Range (min … max):    25.4 ms …  34.7 ms    7 runs


Benchmarking Zig
Benchmark 1:  ./zig/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      34.4 ms ±   1.9 ms    [User: 11.5 ms, System: 10.5 ms]
  Range (min … max):    31.8 ms …  36.6 ms    7 runs


Benchmarking C
Benchmark 1:  ./c/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      17.0 ms ±   0.8 ms    [User: 8.4 ms, System: 1.3 ms]
  Range (min … max):    16.3 ms …  18.4 ms    7 runs


Benchmarking Rust
Benchmark 1:  ./rust/target/release/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      25.1 ms ±   3.3 ms    [User: 13.4 ms, System: 1.3 ms]
  Range (min … max):    21.8 ms …  31.8 ms    7 runs


Benchmarking Dart
Benchmark 1:  ./dart/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      82.6 ms ±   2.4 ms    [User: 58.6 ms, System: 4.1 ms]
  Range (min … max):    78.9 ms …  85.8 ms    7 runs


Benchmarking Objective-C
Benchmark 1:  ./objc/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      22.4 ms ±   0.6 ms    [User: 11.7 ms, System: 1.7 ms]
  Range (min … max):    21.7 ms …  23.5 ms    7 runs


Benchmarking Kotlin JVM
Benchmark 1: java -jar kotlin/code.jar aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      90.6 ms ±   3.1 ms    [User: 83.3 ms, System: 22.3 ms]
  Range (min … max):    85.5 ms …  93.8 ms    7 runs


Benchmarking Node
Benchmark 1: node ./js/code.js aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     105.3 ms ±   2.0 ms    [User: 68.3 ms, System: 4.5 ms]
  Range (min … max):   103.0 ms … 107.7 ms    7 runs


Benchmarking Node (jitless)
Benchmark 1: node --jitless ./js/code.js aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     610.1 ms ±  17.3 ms    [User: 570.8 ms, System: 4.9 ms]
  Range (min … max):   573.3 ms … 627.5 ms    7 runs


Benchmarking Bun
Benchmark 1: bun ./js/code.js aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      47.5 ms ±   1.7 ms    [User: 38.0 ms, System: 4.7 ms]
  Range (min … max):    44.4 ms …  49.2 ms    7 runs


Benchmarking Bun (Compiled)
Benchmark 1:  ./js/bun aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      60.4 ms ±   2.8 ms    [User: 38.1 ms, System: 5.0 ms]
  Range (min … max):    56.7 ms …  65.8 ms    7 runs


Benchmarking Bun (jitless)
Benchmark 1: bun ./js/code.js aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      47.4 ms ±   1.8 ms    [User: 38.1 ms, System: 4.7 ms]
  Range (min … max):    43.6 ms …  48.8 ms    7 runs


Benchmarking Deno (jitless)
Benchmark 1: deno --v8-flags=--jitless ./js/code.js aaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     604.7 ms ±   4.6 ms    [User: 558.0 ms, System: 6.5 ms]
  Range (min … max):   596.1 ms … 611.4 ms    7 runs


Benchmarking Deno
Benchmark 1: deno ./js/code.js aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      90.0 ms ±   2.9 ms    [User: 52.1 ms, System: 5.7 ms]
  Range (min … max):    85.6 ms …  95.3 ms    7 runs


Benchmarking PyPy
Benchmark 1: pypy ./py/code.py aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

  Warning: Ignoring non-zero exit code.
  Time (mean ± σ):      89.2 ms ±   5.1 ms    [User: 14.1 ms, System: 11.6 ms]
  Range (min … max):    84.5 ms …  97.1 ms    7 runs


Benchmarking CPP
Benchmark 1:  ./cpp/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      19.9 ms ±   0.8 ms    [User: 8.7 ms, System: 1.4 ms]
  Range (min … max):    19.0 ms …  21.4 ms    7 runs


Benchmarking Scala
Benchmark 1:  ./scala/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     237.4 ms ±  11.0 ms    [User: 243.1 ms, System: 30.1 ms]
  Range (min … max):   222.5 ms … 249.7 ms    7 runs


Benchmarking Scala-Native
Benchmark 1:  ./scala/code-native aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      19.5 ms ±   3.7 ms    [User: 10.1 ms, System: 1.4 ms]
  Range (min … max):    11.7 ms …  22.9 ms    7 runs


Benchmarking PHP JIT
Benchmark 1: php -dopcache.enable_cli=1 -dopcache.jit=on -dopcache.jit_buffer_si...
  Time (mean ± σ):     257.4 ms ±   3.2 ms    [User: 153.4 ms, System: 11.6 ms]
  Range (min … max):   254.4 ms … 262.9 ms    7 runs


Benchmarking PHP
Benchmark 1: php ./php/code.php aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     719.9 ms ±  10.7 ms    [User: 615.6 ms, System: 11.1 ms]
  Range (min … max):   704.2 ms … 730.4 ms    7 runs


Benchmarking Python
Benchmark 1: python3.13 ./py/code.py aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     799.1 ms ±  17.9 ms    [User: 694.2 ms, System: 7.9 ms]
  Range (min … max):   775.1 ms … 832.0 ms    7 runs


Benchmarking Nim
Benchmark 1:  ./nim/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      32.7 ms ±   1.8 ms    [User: 20.1 ms, System: 1.3 ms]
  Range (min … max):    30.1 ms …  34.7 ms    7 runs


Benchmarking Crystal
Benchmark 1:  ./crystal/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     151.0 ms ±   2.9 ms    [User: 137.9 ms, System: 2.5 ms]
  Range (min … max):   147.7 ms … 154.7 ms    7 runs


Benchmarking Odin
Benchmark 1:  ./odin/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      26.1 ms ±   1.2 ms    [User: 14.2 ms, System: 1.2 ms]
  Range (min … max):    25.2 ms …  28.2 ms    7 runs


Benchmarking Fortran
Benchmark 1:  ./fortran/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      15.3 ms ±   0.4 ms    [User: 6.0 ms, System: 2.3 ms]
  Range (min … max):    14.7 ms …  15.9 ms    7 runs


Benchmarking LuaJIT
Benchmark 1: luajit ./lua/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      76.8 ms ±   5.9 ms    [User: 33.5 ms, System: 2.7 ms]
  Range (min … max):    69.8 ms …  88.9 ms    7 runs


Benchmarking Lua
Benchmark 1: lua ./lua/code.lua aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     580.7 ms ±  11.4 ms    [User: 536.5 ms, System: 2.7 ms]
  Range (min … max):   564.6 ms … 596.9 ms    7 runs


Benchmarking Swift
Benchmark 1:  ./swift/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):      39.8 ms ±   3.3 ms    [User: 27.2 ms, System: 1.3 ms]
  Range (min … max):    35.2 ms …  43.7 ms    7 runs


Benchmarking Julia
Benchmark 1: julia ./julia/code.jl aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     202.2 ms ±   6.0 ms    [User: 340.3 ms, System: 26.6 ms]
  Range (min … max):   198.1 ms … 214.8 ms    7 runs


Benchmarking C#
Benchmark 1:  ./csharp/code/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

  Warning: Ignoring non-zero exit code.
  Time (mean ± σ):      60.4 ms ±   8.3 ms    [User: 22.1 ms, System: 9.6 ms]
  Range (min … max):    44.9 ms …  68.9 ms    7 runs


Benchmarking F#
Benchmark 1:  ./fsharp/code/code aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     100.1 ms ±   1.8 ms    [User: 79.0 ms, System: 8.9 ms]
  Range (min … max):    97.7 ms … 102.6 ms    7 runs


Benchmarking Ruby
Benchmark 1: ruby ./ruby/code.rb aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     810.3 ms ±  30.8 ms    [User: 766.5 ms, System: 8.6 ms]
  Range (min … max):   755.1 ms … 854.7 ms    7 runs


Benchmarking Ruby YJIT
Benchmark 1: miniruby --yjit ./ruby/code.rb aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
  Time (mean ± σ):     419.4 ms ±   3.1 ms    [User: 376.1 ms, System: 3.6 ms]
  Range (min … max):   413.5 ms … 422.7 ms    7 runs

Code

You can find all of the code and the compile / run / cleanup scripts at the GitHub repository.