Skip to main content

Crate subms

Crate subms 

Source
Expand description

subms — a tiny, std-only perf-test harness for Rust programs.

Records timed samples per stage, computes percentiles, and emits a stable JSON shape suitable for upload to submillisecond.com cookbook samples.

Zero external dependencies.

§Example

use subms::PerfHarness;

let mut h = PerfHarness::new("lsm-tree", "rust");
h.input("entries", &50_000.to_string());
h.input("bloom_mode", "on");
h.meta("sstables", "46");

let put = h.stage("put", 50_000);
for _ in 0..50_000 {
    put.time(|| { /* work under test */ });
}

h.write_json(&mut std::io::stdout()).unwrap();

§JSON shape (stable; matches the Java harness in the cookbook)

{
  "workload": "lsm-tree",
  "lang": "rust",
  "timestamp": "2026-05-13T20:24:38Z",
  "inputs":  { "<k>": "<v>", ... },
  "meta":    { "<k>": "<v>", ... },
  "stages": {
    "<name>": {
      "count": <int>,
      "p50_ns": <int>, "p99_ns": <int>, "p999_ns": <int>, "max_ns": <int>,
      "mean_ns": <int>,
      "samples_ns": [<int>, ...]
    }
  }
}

Re-exports§

pub use recipe::benchmark;
pub use recipe::BenchParams;
pub use recipe::Recipe;
pub use util::Lcg;

Modules§

recipe
Recipe trait: a reusable low-latency component plus its standard benchmark stages. The harness (crate::PerfHarness) carries timing samples and emits stable JSON for the submillisecond.com cookbook.
util
Small shared utilities used by cookbook recipes.

Structs§

PerfHarness
A workload run: inputs, metadata, and one or more timed stages.
Stage
Per-stage sample buffer + recorder.

Functions§

read_stdin_kv
Parse stdin key=value lines into a flat map. Skips blank lines and # comments.