mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
use package HAMT in benchmarks
This commit is contained in:
parent
36a81f710e
commit
b091bba431
3 changed files with 31 additions and 1 deletions
1
.merlin
1
.merlin
|
|
@ -33,4 +33,5 @@ PKG threads.posix
|
||||||
PKG lwt
|
PKG lwt
|
||||||
PKG bigarray
|
PKG bigarray
|
||||||
PKG sequence
|
PKG sequence
|
||||||
|
PKG hamt
|
||||||
FLG -w +a -w -4 -w -44 -w -32 -w -34
|
FLG -w +a -w -4 -w -44 -w -32 -w -34
|
||||||
|
|
|
||||||
2
_oasis
2
_oasis
|
|
@ -181,7 +181,7 @@ Executable run_benchs
|
||||||
MainIs: run_benchs.ml
|
MainIs: run_benchs.ml
|
||||||
BuildDepends: containers, containers.misc, containers.advanced,
|
BuildDepends: containers, containers.misc, containers.advanced,
|
||||||
containers.data, containers.string, containers.iter,
|
containers.data, containers.string, containers.iter,
|
||||||
containers.thread, sequence, gen, benchmark
|
containers.thread, sequence, gen, benchmark, hamt
|
||||||
|
|
||||||
Executable run_bench_hash
|
Executable run_bench_hash
|
||||||
Path: benchs/
|
Path: benchs/
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,8 @@ module Tbl = struct
|
||||||
let hash i = i land max_int
|
let hash i = i land max_int
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
module IHAMT = Hamt.Make(Hamt.StdConfig)(CCInt)
|
||||||
|
|
||||||
let phashtbl_add n =
|
let phashtbl_add n =
|
||||||
let h = PHashtbl.create 50 in
|
let h = PHashtbl.create 50 in
|
||||||
for i = n downto 0 do
|
for i = n downto 0 do
|
||||||
|
|
@ -253,6 +255,13 @@ module Tbl = struct
|
||||||
done;
|
done;
|
||||||
!h
|
!h
|
||||||
|
|
||||||
|
let hamt_add n =
|
||||||
|
let h = ref IHAMT.empty in
|
||||||
|
for i = n downto 0 do
|
||||||
|
h := IHAMT.add i i !h;
|
||||||
|
done;
|
||||||
|
!h
|
||||||
|
|
||||||
let icchashtbl_add n =
|
let icchashtbl_add n =
|
||||||
let h = ICCHashtbl.create 50 in
|
let h = ICCHashtbl.create 50 in
|
||||||
for i = n downto 0 do
|
for i = n downto 0 do
|
||||||
|
|
@ -270,6 +279,7 @@ module Tbl = struct
|
||||||
"intmap_add", (fun n -> ignore (intmap_add n)), n;
|
"intmap_add", (fun n -> ignore (intmap_add n)), n;
|
||||||
"ccflathashtbl_add", (fun n -> ignore (icchashtbl_add n)), n;
|
"ccflathashtbl_add", (fun n -> ignore (icchashtbl_add n)), n;
|
||||||
"cchashtrie_add", (fun n -> ignore (hashtrie_add n)), n;
|
"cchashtrie_add", (fun n -> ignore (hashtrie_add n)), n;
|
||||||
|
"hamt_add", (fun n -> ignore (hamt_add n)), n;
|
||||||
]
|
]
|
||||||
|
|
||||||
let phashtbl_replace n =
|
let phashtbl_replace n =
|
||||||
|
|
@ -342,6 +352,16 @@ module Tbl = struct
|
||||||
done;
|
done;
|
||||||
!h
|
!h
|
||||||
|
|
||||||
|
let hamt_replace n =
|
||||||
|
let h = ref IHAMT.empty in
|
||||||
|
for i = 0 to n do
|
||||||
|
h := IHAMT.add i i !h;
|
||||||
|
done;
|
||||||
|
for i = n downto 0 do
|
||||||
|
h := IHAMT.add i i !h;
|
||||||
|
done;
|
||||||
|
!h
|
||||||
|
|
||||||
let icchashtbl_replace n =
|
let icchashtbl_replace n =
|
||||||
let h = ICCHashtbl.create 50 in
|
let h = ICCHashtbl.create 50 in
|
||||||
for i = 0 to n do
|
for i = 0 to n do
|
||||||
|
|
@ -362,6 +382,7 @@ module Tbl = struct
|
||||||
"intmap_replace", (fun n -> ignore (intmap_replace n)), n;
|
"intmap_replace", (fun n -> ignore (intmap_replace n)), n;
|
||||||
"ccflathashtbl_replace", (fun n -> ignore (icchashtbl_replace n)), n;
|
"ccflathashtbl_replace", (fun n -> ignore (icchashtbl_replace n)), n;
|
||||||
"hashtrie_replace", (fun n -> ignore (hashtrie_replace n)), n;
|
"hashtrie_replace", (fun n -> ignore (hashtrie_replace n)), n;
|
||||||
|
"hamt_replace", (fun n -> ignore (hamt_replace n)), n;
|
||||||
]
|
]
|
||||||
|
|
||||||
let phashtbl_find h =
|
let phashtbl_find h =
|
||||||
|
|
@ -418,6 +439,12 @@ module Tbl = struct
|
||||||
ignore (IHashTrie.get_exn i m);
|
ignore (IHashTrie.get_exn i m);
|
||||||
done
|
done
|
||||||
|
|
||||||
|
let hamt_find m =
|
||||||
|
fun n ->
|
||||||
|
for i = 0 to n-1 do
|
||||||
|
ignore (IHAMT.find_exn i m);
|
||||||
|
done
|
||||||
|
|
||||||
let icchashtbl_find m =
|
let icchashtbl_find m =
|
||||||
fun n ->
|
fun n ->
|
||||||
for i = 0 to n-1 do
|
for i = 0 to n-1 do
|
||||||
|
|
@ -435,6 +462,7 @@ module Tbl = struct
|
||||||
let m' = intmap_add n in
|
let m' = intmap_add n in
|
||||||
let h'''''' = icchashtbl_add n in
|
let h'''''' = icchashtbl_add n in
|
||||||
let ht = hashtrie_add n in
|
let ht = hashtrie_add n in
|
||||||
|
let hamt = hamt_add n in
|
||||||
B.throughputN 3 [
|
B.throughputN 3 [
|
||||||
"phashtbl_find", (fun () -> phashtbl_find h n), ();
|
"phashtbl_find", (fun () -> phashtbl_find h n), ();
|
||||||
"hashtbl_find", (fun () -> hashtbl_find h' n), ();
|
"hashtbl_find", (fun () -> hashtbl_find h' n), ();
|
||||||
|
|
@ -446,6 +474,7 @@ module Tbl = struct
|
||||||
"intmap_find", (fun () -> intmap_find m' n), ();
|
"intmap_find", (fun () -> intmap_find m' n), ();
|
||||||
"ccflathashtbl_find", (fun () -> icchashtbl_find h'''''' n), ();
|
"ccflathashtbl_find", (fun () -> icchashtbl_find h'''''' n), ();
|
||||||
"hashtrie_find", (fun () -> hashtrie_find ht n), ();
|
"hashtrie_find", (fun () -> hashtrie_find ht n), ();
|
||||||
|
"hamt_find", (fun () -> hamt_find hamt n), ();
|
||||||
]
|
]
|
||||||
|
|
||||||
let () = B.Tree.register (
|
let () = B.Tree.register (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue