🏎ïļ Microbenchmark Framework

A lightweight OCaml benchmarking framework with automatic calibration, statistical analysis, and comparison charts.

Features

Interactive Demo

Simulated benchmark results (the real framework runs natively in OCaml):

API Usage

(* Simple benchmark *)
let result = Bench.run "My Function" (fun () -> my_function input)

(* Compare implementations *)
Bench.group "Sorting" [
  ("Insertion Sort", fun () -> insertion_sort data);
  ("Merge Sort",     fun () -> merge_sort data);
  ("Array.sort",     fun () -> Array.sort compare (Array.copy data));
]

(* Parametric — measure scaling *)
Bench.parametric "Array.sort Scaling"
  [100; 500; 1000; 5000; 10000]
  (fun n ->
    let data = Array.init n (fun _ -> Random.int 100000) in
    fun () -> Array.sort compare (Array.copy data))

(* Custom config *)
let cfg = { Bench.default_config with
  warmup_iters = 10;
  min_samples = 50;
  min_time = 3.0;
} in
Bench.run ~config:cfg "Precise" my_fn

Statistics Explained

x˄
Mean — average time
x˃
Median — middle value
σ
Std Dev — spread
P5
5th percentile
P95
95th percentile
n
Sample count

← Back to Index