rusty_benchmark 0.1.0

Simple micro-benchmarking helper that writes directly to CSV
Documentation
//! Demonstrates `timing_utils` with two fake “work” functions.
//!
//! Run with:  `cargo run --example basic`

use std::{thread, time::Duration};
use time_measure::{Bench};

// --- some pretend workloads ---------------------------------------------
fn fast_job() {
    // simulate 1 ms of work
    thread::sleep(Duration::from_millis(1));
}

fn slow_job() {
    // simulate 4 ms of work
    thread::sleep(Duration::from_millis(4));
}

fn main() -> anyhow::Result<()> {
    let mut bench = Bench::new();

    // first run
    bench.measure("fast", fast_job);
    bench.measure("slow", slow_job);

    // second run (just to show multiple rows)
    bench.next_run();
    bench.measure("fast", fast_job);
    bench.measure("fast_again", fast_job);      // a label we didn't use before
    bench.measure("slow", slow_job);

    // write   run,fast_ns,fast_again_ns,slow_ns,total_ns
    bench.save_to_csv("examples/bench.csv")?;

    Ok(())
}