Module Bench

module Bench: Bench


Bench is a micro-benchmarking library that attempts to measure the execution time, allocation, GC effects etc of a function. Here is a simple example of using bench:

{ open Core.Std open Core_bench.Std let main () = let t1 = Bench.Test.create ~name:"ArrayCreateInt1" (fun () -> ignore (Array.create ~len:200 0)) in let t2 = Bench.Test.create ~name:"ArrayCreateInt2" (fun () -> ignore (Array.create ~len:300 0)) in Command.run (Bench.make_command [t1; t2;]) let () = main () }

For some notes on the design space of bench and TODO items, see: http://docs/programming/performance/benchmarking.html

module Test: sig .. end
module Variable: sig .. end
module Run_config: sig .. end
For default values of all the optional arguments, see the module called Defaults in bench_main.ml.
module Display_config: sig .. end
module Analysis_config: sig .. end
module Measurement: sig .. end
val bench : ?run_config:Run_config.t ->
?analysis_configs:Analysis_config.t list ->
?display_config:Display_config.t -> Test.t list -> unit
The documentation for all of these arguments is in the implementation, as documentation for the command line flags created by make_command.
val measure : ?run_config:Run_config.t ->
Test.t list -> Measurement.t list
val analyze : ?analysis_configs:Analysis_config.t list ->
Measurement.t -> Analysis_result.t Core.Std.Or_error.t
val display : ?display_config:Display_config.t -> Analysis_result.t list -> unit
val save_measurements : Measurement.t list ->
to_filename:(Measurement.t -> string) -> unit
val load_measurements : filenames:string list -> Measurement.t list
val make_command : Test.t list -> Core.Std.Command.t
val make_command_ext : summary:string ->
extra_spec:('a, unit -> unit) Core.Std.Command.Spec.t ->
f:(Analysis_config.t list * Display_config.t *
[ `From_file of string list
| `Run of (Measurement.t -> string) option * Run_config.t ] ->
'a) ->
Core.Std.Command.t