hn.today

Benchfmt.rs: Bringing Go's benchmarking and benchstat workflow to Rust

bwplotka.dev30 points7 comments
Screenshot of Benchfmt.rs: Bringing Go's benchmarking and benchstat workflow to Rust

Benchfmt.rs is a Rust benchmarking tool designed to bring Go’s familiar bench and benchstat workflow to Rust. It provides a zero-dependency runner with Go-compatible benchmark output, `/key=value` dimensions for comparing cases, allocation reporting in bytes and objects per operation, and pprof profiling support. Developers using existing Rust tools can also convert Criterion and libtest results into the same format. The goal is to make repeated A/B comparisons and cross-language performance tests easier, with outputs that benchstat can analyze consistently.

The demonstrations implement two decoders in Go and Rust: a varint decoder that processes 2,000 values without allocating, and a Snappy-compressed Prometheus Remote Write 2.0 decoder tested on batches of 200 and 2,000 series. The comparison uses repeated timed runs on the same Linux workstation; Go uses optimized generated protobuf decoding, while Rust uses prost and snap. Criterion can run the Rust tests, but requires care with optimization barriers and does not natively provide the same allocation and profiling workflow. The benchmarks show Rust ahead in the tested workloads, while profiling helps identify where decoding time and memory use arise rather than treating a single timing as an explanation. The broader lesson is that trustworthy comparisons require matching workloads, repeated measurements, allocation data, and tools for investigating overhead.

Read on bwplotka.dev7 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.