use package HAMT in benchmarks

This commit is contained in:
Simon Cruanes 2015-09-05 00:02:02 +02:00
parent 36a81f710e
commit b091bba431
3 changed files with 31 additions and 1 deletions

View file

@ -33,4 +33,5 @@ PKG threads.posix
PKG lwt
PKG bigarray
PKG sequence
PKG hamt
FLG -w +a -w -4 -w -44 -w -32 -w -34

2
_oasis
View file

@ -181,7 +181,7 @@ Executable run_benchs
MainIs: run_benchs.ml
BuildDepends: containers, containers.misc, containers.advanced,
containers.data, containers.string, containers.iter,
containers.thread, sequence, gen, benchmark
containers.thread, sequence, gen, benchmark, hamt
Executable run_bench_hash
Path: benchs/

View file

@ -204,6 +204,8 @@ module Tbl = struct
let hash i = i land max_int
end)
module IHAMT = Hamt.Make(Hamt.StdConfig)(CCInt)
let phashtbl_add n =
let h = PHashtbl.create 50 in
for i = n downto 0 do
@ -253,6 +255,13 @@ module Tbl = struct
done;
!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 h = ICCHashtbl.create 50 in
for i = n downto 0 do
@ -270,6 +279,7 @@ module Tbl = struct
"intmap_add", (fun n -> ignore (intmap_add n)), n;
"ccflathashtbl_add", (fun n -> ignore (icchashtbl_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 =
@ -342,6 +352,16 @@ module Tbl = struct
done;
!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 h = ICCHashtbl.create 50 in
for i = 0 to n do
@ -362,6 +382,7 @@ module Tbl = struct
"intmap_replace", (fun n -> ignore (intmap_replace n)), n;
"ccflathashtbl_replace", (fun n -> ignore (icchashtbl_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 =
@ -418,6 +439,12 @@ module Tbl = struct
ignore (IHashTrie.get_exn i m);
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 =
fun n ->
for i = 0 to n-1 do
@ -435,6 +462,7 @@ module Tbl = struct
let m' = intmap_add n in
let h'''''' = icchashtbl_add n in
let ht = hashtrie_add n in
let hamt = hamt_add n in
B.throughputN 3 [
"phashtbl_find", (fun () -> phashtbl_find h n), ();
"hashtbl_find", (fun () -> hashtbl_find h' n), ();
@ -446,6 +474,7 @@ module Tbl = struct
"intmap_find", (fun () -> intmap_find m' n), ();
"ccflathashtbl_find", (fun () -> icchashtbl_find h'''''' n), ();
"hashtrie_find", (fun () -> hashtrie_find ht n), ();
"hamt_find", (fun () -> hamt_find hamt n), ();
]
let () = B.Tree.register (