Tms value type ready
Benchmark::Tms: utime, stime, cutime, cstime, real, the derived total = utime+stime+cutime+cstime, and a label, with ToA / ToS and MRI-exact constructor semantics (a sum’s label clears to "").
Ruby's Benchmark module in pure Go โ MRI-compatible, no cgo.
go-ruby-benchmark is a pure-Go (no cgo) reimplementation of Ruby's standard-library Benchmark module โ the deterministic, interpreter-independent core of MRI 4.0.5: the Tms measurement value type, its memberwise arithmetic and %-directive formatting, and the report layout (CAPTION, label justification, the bm / bmbm / benchmark tables). It reproduces MRI's formatted output byte-for-byte. The one impure ingredient โ the clock โ is injected: MRI's Benchmark.measure reads Process.times and clock_gettime(CLOCK_MONOTONIC), and this library takes those readings through a small Clock interface, so every formatted line is reproducible in tests. It was extracted from rbgo's internals into a reusable standalone library: no dependency on the Ruby runtime, the dependency runs the other way. It is the Benchmark backend for go-embedded-ruby, bound by rbgo as a native module just like go-ruby-regexp and go-ruby-erb โ differential-tested against MRI, 100% coverage, CI green across 6 arches and 3 OSes.
Benchmark::Tms: utime, stime, cutime, cstime, real, the derived total = utime+stime+cutime+cstime, and a label, with ToA / ToS and MRI-exact constructor semantics (a sum’s label clears to "").
Add / Sub / Mul / Div against another Tms, and the scalar forms applied to all five fields (real included) โ exactly as MRI’s Tms#+ - * / do.
The Benchmark %-extensions on top of printf: %u user, %y system, %U / %Y children’s, %t total, %r real (parenthesised), %n label โ each preserving its flag/width/precision run, with %% collapse and surplus-arg drop matching String#%.
CAPTION, label left-justification, and the full bm(width), bmbm (rehearsal banner + total footer + take table), and general benchmark(caption, width, format, *labels) tables with trailing summary lines โ all pure functions over Tms.
MeasureWith, RealtimeWith, MsWith, and Tms.AddWith take a Clock seam (Process.times + clock_gettime(CLOCK_MONOTONIC)): the host supplies the real process clock, tests a deterministic one, so every formatted line is reproducible.
The same fixed numbers and a patched, deterministic clock fed to the system ruby’s Benchmark and compared byte-for-byte; 100% coverage, gofmt + go vet clean, green across all six 64-bit Go arches and three OSes.
A faithful port of Ruby's Benchmark module in pure Go, cgo disabled, so it cross-compiles and embeds anywhere. It implements the Tms value type, its memberwise and scalar arithmetic, the %u %y %t %r format directives, and the bm / bmbm / benchmark report tables โ all pure functions over Tms, with the one impure ingredient (the clock) injected through a Clock seam. Validated differentially against the system ruby binary โ the same fixed numbers and a deterministic clock compared byte-for-byte. It is a standalone, reusable module extracted from rbgo's internals, and the Benchmark backend for the sibling org github.com/go-embedded-ruby.