Benchmarks

View Source

The following numbers were produced by just bench-compare on an Apple M1 Pro running OTP 29. The base62 column is the optimized implementation; legacy is the frozen pre-optimization snapshot under bench/legacy/base62_legacy.erl.

Each row is the faster of the two (bolded). ips = iterations per second; mean/median/p99 are per-operation latency; memory is the size of the result binary per operation.

Encode (64 B)

Libraryipsmeanmedianp99memory
base621.5M679.22 ns500.00 ns3.13 μs91 B
legacy675.5K1.48 μs1.21 μs4.96 μs91 B

Decode (64 B)

Libraryipsmeanmedianp99memory
base62860.6K1.16 μs959.00 ns4.00 μs64 B
legacy643.1K1.55 μs1.29 μs5.71 μs64 B

Encode (1 KB)

Libraryipsmeanmedianp99memory
base62104.1K9.60 μs9.08 μs16.92 μs1.40 KB
legacy42.9K23.33 μs20.88 μs48.13 μs1.40 KB

Decode (1 KB)

Libraryipsmeanmedianp99memory
base6269.8K14.32 μs13.92 μs20.92 μs1.00 KB
legacy44.5K22.49 μs22.08 μs29.13 μs1.00 KB

Encode (16 KB)

Libraryipsmeanmedianp99memory
base623.9K254.92 μs253.38 μs304.75 μs22.36 KB
legacy3.0K336.67 μs331.83 μs381.96 μs22.36 KB

Decode (16 KB)

Libraryipsmeanmedianp99memory
base623.6K278.71 μs270.54 μs367.75 μs16.00 KB
legacy2.6K384.82 μs377.58 μs470.96 μs16.00 KB

Encode (64 KB)

Libraryipsmeanmedianp99memory
base62935.31.07 ms1.05 ms1.51 ms89.38 KB
legacy729.01.37 ms1.35 ms1.60 ms89.38 KB

Decode (64 KB)

Libraryipsmeanmedianp99memory
base62889.01.12 ms1.11 ms1.26 ms64.00 KB
legacy651.11.54 ms1.52 ms1.72 ms64.00 KB

Running the benchmarks

just bench          # current base62 only
just bench-compare  # A/B against the frozen legacy snapshot

The bench-compare recipe builds bench/legacy/base62_legacy.beam on demand if it does not already exist.