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.
Benchmarkval time : (unit -> 'a) -> 'a * float t
time 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 t
timeit ?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 () ;
done
timeit
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 -> unit
val pp_float_t : Stdlib.Format.formatter -> float t -> unit
val pp_timedelta : Stdlib.Format.formatter -> float -> unit
val pp_stat : Stdlib.Format.formatter -> stat -> unit
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4