Reading the results
Read down a column to compare implementations on the same input. Start with the metric and baseline, then check the spread before acting on a small lead.
The text table
Section titled “The text table”Join 1000 words Rate StringBuffer 49.32K ops/s join 109.51K ops/s [best] (2.22x faster) + operator 3.62K ops/s (13.63x slower)- Top-left is the group name: the name you gave
group(orcompare). - The column header is the metric (here
Rate), or formatrix, the input of that column. - The first row is the default baseline. Other rows show how much faster or slower they are than it, in the same column.
[best]marks the best score in a column (lowest time for runtime).
Metrics: what the numbers mean
Section titled “Metrics: what the numbers mean”| You see | Metric | Meaning | Better is |
|---|---|---|---|
109.51K ops/s |
Rate | runs per second | higher |
4.2 Gbps |
Throughput | bits processed per second, from the size you give |
higher |
8.58M chars/s |
Metric.perSecond('chars') |
your unit per second | higher |
9.13 us |
Runtime | time of one run | lower |
Suffixes: K is thousand, M million, G billion. Times use ns
(nanoseconds), us (microseconds), ms (milliseconds) and s; one
microsecond is a millionth of a second.
benchmark, compare and matrix show Rate unless you give a size,
which switches to Throughput.
When the table shows ≈ same
Section titled “When the table shows ≈ same”Same work twice Rate first 109.51K ops/s second 109.66K ops/s [best] (≈ same)The second row has the higher measured rate. The sample comparison did
not detect a significant difference at the configured level (0.05 by
default). The mark alone cannot establish that the implementations perform
equally. If the difference matters, repeat the run on representative inputs.
Markdown and HTML display the same result with a trailing ≈.
Markdown and HTML tables
Section titled “Markdown and HTML tables”With --format=md (or html), cells get a bar and marks:
| Benchmark | Variant | Rate || --------------- | ------------ | ------------------------------------------------- || Join 1000 words | StringBuffer | `███████░░░░░░░░░` <br> 49.58K ops/s || | join | `████████████████` <br> **109.49K ops/s** 🔺2.21x || | + operator | `█░░░░░░░░░░░░░░░` <br> 3.61K ops/s 🔻13.72x |- The bar shows each value next to the best one; a full bar is the best.
- Bold is the best value in the column.
- 🔺2.21x: that many times faster than the baseline row; 🔻: slower.
- 🌟 marks the best cell when no ratio is shown next to it.
All of these can be changed or turned off with CellStyle.
Warnings
Section titled “Warnings”Sometimes a table ends with a warning:
Warning: "g / fast" takes 0.5 ns per run in "x": its work may have beenoptimized away. Return the result from run().- Under 1 ns per run. Check that the function returns its result and that the compiler has work to do on each call.
- Time barely changes as input grows. Check how much of each input the function should visit. Constant time can be expected for an indexed lookup.
The one-line summary
Section titled “The one-line summary”measureRate on a benchmark class prints a single line:
+ operator: 8.51M chars/s | 117.55 us/run ±0.4% (2580 runs, 60 samples)8.51M chars/s: the metric.117.55 us/run: the representative time of one run, the low end of the batch samples.±0.4%: the typical batch’s distance from the median, as a fraction of that low end. Under about 2% is steady; above 5%, close other programs and run again.2580 runs, 60 samples: runs are grouped into samples, and each sample is timed as a whole.
Comparing with a saved run
Section titled “Comparing with a saved run”--baseline=FILE adds a table of changes:
Benchmark Before After Change VerdictJoin 1000 words / StringBuffer / Rate 20.27 us 20.38 us +0.5% unchangedJoin 1000 words / join / Rate 9.14 us 9.13 us -0.1% unchangedJoin 1000 words / + operator / Rate 278.56 us 275.28 us -1.2% unchanged
3 unchanged- Before / After are times per run, so lower is better and
+means slower. - Verdict is
regression(slower),improvement(faster) orunchanged. A change counts only if it is bigger than the threshold (5% unless you pass--threshold) and passes the significance check when both runs have enough samples.addedandremovedmark benchmarks found in only one of the runs. - Any regression makes the program exit with code 1, which fails a CI job.
When the run stops with an error
Section titled “When the run stops with an error”OutputMismatchError: "join with spaces" returned word0 word1 word2 ...,but "join" returned word0word1word2 ...You ran with --verify and two benchmarks in a group returned different
results. Fix the one that is wrong, or leave out --verify if the results are
meant to differ.