bench/binary tutorial

This page shows how to run the binary arithmetic and elementary-function benchmarks and how to read their output. The suite compares implementation paths on identical inputs with paired measurements; see the bench tutorial for the toolkit and the artifact format.

I want toUse
run the suitejust bench binary
run only the elementary functionsjust bench elementary
read the reported percentagesMAREMARK_HOTSPOT lines
check that the specifications still compilethe plan tests
change workloads or pathsthe *_test.mbt files
understand the statisticsbench design

Quick start

The suite runs from a checkout of the repository; it is not part of the published package, so there is nothing to moon add. From the repository root:

just bench binary
just bench elementary

The runner executes the skipped performance tests of tooling/src/bench/binary on the native target in release mode and writes .tmp/bench/SUITE.jsonl (all observations) and .tmp/bench/SUITE.analysis.txt (the reduced lines), where SUITE is the name given to just bench.

Everyday tasks

Read the analysis lines

The analysis file contains MAREMARK_HOTSPOT=binary/OP/DATASET core_pct=… full_pct=… for arithmetic, MAREMARK_HOTSPOT=binary/elementary/OP/DATASET full_pct=… for elementary functions. A core_pct value is the median paired difference between the core path and the kernel, in percent of the kernel’s median time; full_pct is the same for the checked path against the core path. Positive values mean the higher layer is slower.

Check the plans without measuring

sh tools/run_moon_clean_exec.sh test tooling/src/bench/binary --target native

runs only the plan tests, which compile every specification.

Going further

  • Change datasets or implementations in the *_test.mbt files; keep the reference oracle so a faster but wrong path fails the run.
  • Compare two runs only when their recorded environments agree.
  • The performance audit and the performance/ pages summarize measured results.

Common pitfalls

  • Benchmarks are skipped in normal moon test runs; use just bench.
  • Results depend on the machine; percentages are more stable than absolute microseconds.

Next steps