Skip to content

Benchmark Result Format ​

Benchmark tasks must write JSON to stdout in the following format. Reprobench captures stdout and saves it to the configured output path.

Schema ​

json
{
  "project": "my-library",
  "timestamp": "2024-01-01T00:00:00Z",
  "benchmarks": [
    {
      "name": "encode single-small",
      "group": "speed",
      "value": 16038,
      "unit": "ops/s"
    },
    {
      "name": "batch-homogeneous-256",
      "group": "size",
      "value": 5316,
      "unit": "bytes"
    }
  ]
}

Fields ​

Top-level ​

FieldTypeRequiredDescription
projectstringNoProject name
timestampstringNoISO 8601 timestamp
environmentobjectNoArbitrary environment metadata
benchmarksarrayYesList of benchmark entries

Benchmark entry ​

FieldTypeRequiredDescription
namestringYesBenchmark name. Must match guard names exactly.
groupstringNoGroup label used in reports (e.g. "speed", "size")
valuenumberYesMeasured value
unitstringYesUnit of the value
directionstringNoOverride direction: "lower-is-better" or "higher-is-better"
metadataobjectNoArbitrary extra data

Supported units ​

Direction is inferred from the unit when direction is not set:

UnitInferred direction
byteslower-is-better
mslower-is-better
slower-is-better
ops/shigher-is-better
counthigher-is-better
(any other)higher-is-better

Minimal example script (Node.js) ​

js
const result = {
  project: "my-library",
  timestamp: new Date().toISOString(),
  benchmarks: [
    {
      name: "encode",
      group: "speed",
      value: measureOpsPerSec(),
      unit: "ops/s",
    },
    {
      name: "output-size",
      group: "size",
      value: measureBytes(),
      unit: "bytes",
    },
  ],
};

process.stdout.write(JSON.stringify(result) + "\n");

WARNING

Only write JSON to stdout. Any other output (logs, warnings) must go to stderr, or the result file will fail to parse.

Released under the MIT License.