Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/nornir

examples/nornir-bench.rs

//! nornir's OWN bench RUNNER — nornir dogfooding its bench engine.
//!
//! Mirrors the contract every child repo (`znippy`, `holger`, `facett`, …)
//! implements: a `main` of just [`run_main_json`]. The benchers themselves are
//! registered IN the `nornir` library (`src/bench_registry.rs`) via
//! [`register_bench!`], not here — so `inventory` links them into the library and
//! thus into the release completeness-gate binary, where the bencher-discovery
//! seam ([`nornir::bench::api::registered_bench_ids`]) can actually see them. This
//! example just links that library, so `run_main_json()` collects the same
//! `inventory` registrations and runs them. (Previously the benchers lived here,
//! in the example, which is NOT linked into the lib — so the gate saw zero.)
//!
//! Run:
//!
//!     cargo run --release --example nornir-bench
//!
//! Single-core (`_st`) pass too (the speedup denominator):
//!
//!     NORNIR_BENCH_ST=1 cargo run --release --example nornir-bench
//!
//! ## Benches
//!
//! See `src/bench_registry.rs` for the registered benchers
//! (`nornir.dep_graph_build` / `nornir.dep_graph_build_ext`).

use anyhow::Result;

fn main() -> Result<()> {
    // Default machine so the run is appendable if piped into the warehouse.
    if std::env::var_os("NORNIR_MACHINE").is_none() {
        unsafe { std::env::set_var("NORNIR_MACHINE", "nornir-bench") };
    }
    nornir::bench::api::run_main_json()
}