Jupyter_notebook.BenchBenchmark functions
type 'a t = {b_rtime : 'a;Real time for the process
*)b_utime : 'a;User time for the process
*)b_stime : 'a;System time for the process
*)}The type of execution time of functions or code snippets.
'a is float or stat.
type stat = {bs_mean : float;Mean of execution time per a loop
*)bs_std : float;Standard deviation of execution time per a loop
*)}The type of summary results of repeated measurement of execution time.
val time : (unit -> 'a) -> 'a * float ttime f measures execution time of a function f.
val timeit :
?runs:int ->
?loops_per_run:int ->
?before_run:(unit -> unit) ->
?after_run:(unit -> unit) ->
(unit -> 'a) ->
stat ttimeit ?runs ?loops_per_run ?before_run ?after_run f repeatedly executes a function f, and measures the mean and the standard deviation of each execution time of f ().
for i = 1 to runs do
before_run () ;
(* --- start measurement of execution time of each run --- *)
for _ = 1 to loops_per_run do
ignore (f ()) ;
done ;
(* --- finish measurement --- *)
after_run () ;
donetimeit is inspired by timeit package in Python. The parameter loops_per_run, before_run are named as number, setup respectively in Python.
val pp :
(Stdlib.Format.formatter -> 'a -> unit) ->
Stdlib.Format.formatter ->
'a t ->
unitval pp_float_t : Stdlib.Format.formatter -> float t -> unitval pp_stat : Stdlib.Format.formatter -> stat -> unit