mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
simpler interface for CCbench global registration
This commit is contained in:
parent
b8d84de4dc
commit
ac0f18d3c7
3 changed files with 22 additions and 31 deletions
|
|
@ -238,10 +238,9 @@ let run_main ?(argv=Sys.argv) ?(out=Format.std_formatter) t =
|
|||
|
||||
(** {2 Global Registration} *)
|
||||
|
||||
module Glob = struct
|
||||
let tree_ = ref (Multiple ([], SMap.empty))
|
||||
|
||||
let get () = !tree_
|
||||
let global_bench () = !tree_
|
||||
|
||||
let register ?(path=[]) new_t =
|
||||
tree_ := merge_ !tree_ (prefix path new_t)
|
||||
|
|
@ -251,4 +250,3 @@ module Glob = struct
|
|||
|
||||
let run_main ?argv ?out () =
|
||||
run_main ?argv ?out !tree_
|
||||
end
|
||||
|
|
|
|||
|
|
@ -97,19 +97,17 @@ val run_main :
|
|||
|
||||
(** {2 Global Registration} *)
|
||||
|
||||
module Glob : sig
|
||||
val register : ?path:path -> bench -> unit
|
||||
(** Register a benchmark to the global register of benchmarks (a global tree) *)
|
||||
|
||||
val register' : path:string -> bench -> unit
|
||||
(** Same as {!register} but applies {!parse_path} first to its argument *)
|
||||
|
||||
val get : unit -> bench
|
||||
(** Global bench tree *)
|
||||
val global_bench : unit -> bench
|
||||
(** Global bench tree, built from calls to {!register} *)
|
||||
|
||||
val run_main :
|
||||
?argv:string array ->
|
||||
?out:Format.formatter ->
|
||||
unit -> unit
|
||||
(** Same as {!run_main} but on the global tree of benchmarks *)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ module L = struct
|
|||
|
||||
(* MAIN *)
|
||||
|
||||
let bench = CCBench.(
|
||||
let () = CCBench.register CCBench.(
|
||||
"list" >:::
|
||||
[ "flat_map" >::
|
||||
map_int
|
||||
|
|
@ -64,8 +64,6 @@ module L = struct
|
|||
; bench_append ~time:4, 100_000]
|
||||
]
|
||||
)
|
||||
|
||||
let () = CCBench.Glob.register bench
|
||||
end
|
||||
|
||||
module Vec = struct
|
||||
|
|
@ -105,18 +103,15 @@ module Vec = struct
|
|||
; "append_naive", try_append_ append_naive_ n v2, ()
|
||||
]
|
||||
|
||||
let bench = CCBench.(
|
||||
let () = CCBench.register CCBench.(
|
||||
"vector" >:::
|
||||
[ "map" >:: with_int bench_map [100; 10_000; 100_000]
|
||||
; "append" >:: with_int bench_append [100; 10_000; 50_000]
|
||||
]
|
||||
)
|
||||
|
||||
let () =
|
||||
CCBench.Glob.register bench
|
||||
end
|
||||
|
||||
let () =
|
||||
CCBench.Glob.run_main ()
|
||||
CCBench.run_main ()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue