A lightweight OCaml benchmarking framework with automatic calibration, statistical analysis, and comparison charts.
Simulated benchmark results (the real framework runs natively in OCaml):
(* 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