mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
cli options for benchs
This commit is contained in:
parent
a3b4e28295
commit
11259c9297
1 changed files with 24 additions and 7 deletions
|
|
@ -87,7 +87,7 @@ let imap_add n =
|
||||||
done;
|
done;
|
||||||
!h
|
!h
|
||||||
|
|
||||||
let _ =
|
let bench_maps1 () =
|
||||||
Format.printf "----------------------------------------@.";
|
Format.printf "----------------------------------------@.";
|
||||||
let res = Bench.bench_n
|
let res = Bench.bench_n
|
||||||
["phashtbl_add", (fun n -> ignore (phashtbl_add n));
|
["phashtbl_add", (fun n -> ignore (phashtbl_add n));
|
||||||
|
|
@ -182,7 +182,7 @@ let imap_replace n =
|
||||||
done;
|
done;
|
||||||
!h
|
!h
|
||||||
|
|
||||||
let _ =
|
let bench_maps2 () =
|
||||||
Format.printf "----------------------------------------@.";
|
Format.printf "----------------------------------------@.";
|
||||||
let res = Bench.bench_n
|
let res = Bench.bench_n
|
||||||
["phashtbl_replace", (fun n -> ignore (phashtbl_replace n));
|
["phashtbl_replace", (fun n -> ignore (phashtbl_replace n));
|
||||||
|
|
@ -253,7 +253,7 @@ let imap_find m =
|
||||||
ignore (IMap.find i m);
|
ignore (IMap.find i m);
|
||||||
done
|
done
|
||||||
|
|
||||||
let _ =
|
let bench_maps3 () =
|
||||||
List.iter
|
List.iter
|
||||||
(fun len ->
|
(fun len ->
|
||||||
let h = phashtbl_add len in
|
let h = phashtbl_add len in
|
||||||
|
|
@ -280,18 +280,23 @@ let _ =
|
||||||
])
|
])
|
||||||
[10;20;100;1000;10000]
|
[10;20;100;1000;10000]
|
||||||
|
|
||||||
|
let bench_maps() =
|
||||||
|
bench_maps1 ();
|
||||||
|
bench_maps2 ();
|
||||||
|
bench_maps3 ();
|
||||||
|
()
|
||||||
|
|
||||||
(** {2 Sequence/Gen} *)
|
(** {2 Sequence/Gen} *)
|
||||||
|
|
||||||
let _ =
|
let bench_enum () =
|
||||||
let n = 1_000_000 in
|
let n = 1_000_000 in
|
||||||
let seq () = Sequence.fold (+) 0 (Sequence.int_range ~start:0 ~stop:n) in
|
let seq () = Sequence.fold (+) 0 (Sequence.int_range ~start:0 ~stop:n) in
|
||||||
let enum () = Gen.fold (+) 0 (Gen.int_range 0 n) in
|
let enum () = Gen.fold (+) 0 (Gen.int_range 0 n) in
|
||||||
Bench.bench
|
Bench.bench
|
||||||
[ "sequence.fold", seq;
|
[ "sequence.fold", seq;
|
||||||
"gen.fold", enum;
|
"gen.fold", enum;
|
||||||
]
|
];
|
||||||
|
|
||||||
let _ =
|
|
||||||
let n = 100_000 in
|
let n = 100_000 in
|
||||||
let seq () =
|
let seq () =
|
||||||
let open Sequence in
|
let open Sequence in
|
||||||
|
|
@ -345,7 +350,7 @@ end)
|
||||||
|
|
||||||
module DummyIntCache = Cache.Dummy(struct type t = int end)
|
module DummyIntCache = Cache.Dummy(struct type t = int end)
|
||||||
|
|
||||||
let _ =
|
let bench_cache () =
|
||||||
(* Fibonacci for those caching implementations *)
|
(* Fibonacci for those caching implementations *)
|
||||||
let module LinearFibo = Fibo(LinearIntCache) in
|
let module LinearFibo = Fibo(LinearIntCache) in
|
||||||
let module ReplacingFibo = Fibo(ReplacingIntCache) in
|
let module ReplacingFibo = Fibo(ReplacingIntCache) in
|
||||||
|
|
@ -367,3 +372,15 @@ let _ =
|
||||||
conf.Bench.samples <- 1000;
|
conf.Bench.samples <- 1000;
|
||||||
()
|
()
|
||||||
|
|
||||||
|
let _ =
|
||||||
|
match Sys.argv with
|
||||||
|
| [| _; "maps" |] -> bench_maps ()
|
||||||
|
| [| _; "enum" |] -> bench_enum ()
|
||||||
|
| [| _; "cache" |] -> bench_cache ()
|
||||||
|
| [| _; ("-help" | "--help") |] -> print_endline "./benchs [maps|enum|cache]"
|
||||||
|
| [| _ |] ->
|
||||||
|
bench_enum ();
|
||||||
|
bench_maps ();
|
||||||
|
bench_cache ();
|
||||||
|
()
|
||||||
|
| _ -> failwith "unknown argument (-help)"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue