Benchmarks

zhhz ships the same Rust conversion core in four channels (CLI, Rust library, npm/WebAssembly, Python). The numbers below compare each channel’s throughput on representative Chinese text.

Methodology

Results (MB/s, median of 5 runs)

config CLI (native) npm (WASM) Deno (WASM) Python (PyO3) Rust (rlib)
s2t 88 63 58 ~85 (same engine) ~85 (same engine)
s2twp ~88 41 39 ~85 ~85
t2s ~88 104 108 ~85 ~85

The CLI / Python / Rust numbers are all roughly the same — they share the Rust conversion core; the per-binding overhead is small.

The WASM columns (npm + Deno) are interesting:

One-shot vs instance (npm)

For the npm channel specifically, the per-call cost of building a Converter instance matters:

// Slower: each convert() call builds a new Converter (~1.3x).
import { convert } from "zhhz";
convert(text, "s2t");

// Faster: build once, reuse many times.
import { Converter } from "zhhz";
const c = new Converter("s2t");
c.convert(text);

The benchmark script (tests/bench-node.mjs) measures both. For a hot loop over many texts, build the Converter once at the top.

Why no full opencc-js comparison?

opencc-js doesn’t expose a programmatic benchmark surface comparable to zhhz’s. Apples-to-apples would require either re-implementing opencc-js’s dictionary loader (significant work) or relying on published numbers from third parties.

The numbers that are comparable:

Why no full opencc binary comparison?

We have it, internally: see examples/parity.rs (CI step “Differential parity against opencc”) which runs opencc 1.3.1 against the same dictionary data. Byte-for-byte equality on all 538 supported-config cases is verified on every PR.

For raw MB/s, the native CLI v0.7.7 cross-platform report is in the release notes; for the npm channel, the data above is the canonical local measurement.

See also