Performance¶
go-ruby-format/format is the pure-Go library that
rbgo binds for Ruby's format. This
page records a comparative benchmark of that module against the reference
Ruby runtimes, part of the ecosystem-wide per-module parity suite.
What is measured¶
The same Ruby script — sprintf with mixed conversions (%d %s %f %x %o %+d %e) in a tight loop — is run under every runtime. rbgo's
number reflects this pure-Go library doing the work; every other column is
that interpreter's own format stdlib. So the comparison is the Ruby-visible
operation, apples-to-apples across interpreters. The script prints a
deterministic checksum and its output is checked byte-identical to MRI
before timing.
- Host: Apple M4 Max, macOS (darwin/arm64). Method: best-of-5 wall time (best, not mean, to suppress scheduler noise); single-shot processes, no warm-up beyond the script's own loop.
- Runtimes:
ruby 4.0.5 +PRISM(MRI, the oracle) andruby --yjit;jruby 10.1.0.0(OpenJDK 25);truffleruby 34.0.1(GraalVM CE Native). - The benchmark script and harness live in rbgo's repo under
bench/modules/(format.rb+run.sh). Reproduce:RBGO=./rbgo TRUFFLE=truffleruby bash bench/modules/run.sh 5.
Result (best of 5, ms)¶
| Runtime | time | vs MRI |
|---|---|---|
| rbgo (go-ruby-format) | 640 | 1.94× |
| MRI (ruby 4.0.5) | 330 | 1.00× |
| MRI + YJIT | 310 | 0.94× |
| JRuby 10.1.0.0 | 1490 | 4.52× |
| TruffleRuby 34.0.1 | 480 | 1.45× |
rbgo runs on go-ruby-format. The mixed-conversion sprintf loop is ~1.9x MRI / ~2.1x YJIT — within the clean-interpreter band; the per-iteration cost is dominated by interpreter dispatch around the format call, not the formatter itself.
Honest framing
JRuby and TruffleRuby are timed cold, single-shot, so they carry JVM /
Graal startup on every run — read them as one-shot ruby file.rb costs, the
same way rbgo and MRI are measured, not as steady-state JIT numbers. Rows
that complete in well under ~200 ms carry the most relative noise; treat
their ratios as order-of-magnitude. These are real measured numbers from the
2026-06-29 run — nothing is cherry-picked.