mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 12:45:34 -05:00
update benchmark: add CCIntMap to tbl bench
This commit is contained in:
parent
c8005f388a
commit
d0c270504a
1 changed files with 27 additions and 2 deletions
|
|
@ -235,6 +235,13 @@ module Tbl = struct
|
|||
done;
|
||||
!h
|
||||
|
||||
let intmap_add n =
|
||||
let h = ref CCIntMap.empty in
|
||||
for i = n downto 0 do
|
||||
h := CCIntMap.add i i !h;
|
||||
done;
|
||||
!h
|
||||
|
||||
let icchashtbl_add n =
|
||||
let h = ICCHashtbl.create 50 in
|
||||
for i = n downto 0 do
|
||||
|
|
@ -249,6 +256,7 @@ module Tbl = struct
|
|||
"ihashtbl_add", (fun n -> ignore (ihashtbl_add n)), n;
|
||||
"ipersistenthashtbl_add", (fun n -> ignore (ipersistenthashtbl_add n)), n;
|
||||
"imap_add", (fun n -> ignore (imap_add n)), n;
|
||||
"intmap_add", (fun n -> ignore (intmap_add n)), n;
|
||||
"ccflathashtbl_add", (fun n -> ignore (icchashtbl_add n)), n;
|
||||
]
|
||||
|
||||
|
|
@ -302,6 +310,16 @@ module Tbl = struct
|
|||
done;
|
||||
!h
|
||||
|
||||
let intmap_replace n =
|
||||
let h = ref CCIntMap.empty in
|
||||
for i = 0 to n do
|
||||
h := CCIntMap.add i i !h;
|
||||
done;
|
||||
for i = n downto 0 do
|
||||
h := CCIntMap.add i i !h;
|
||||
done;
|
||||
!h
|
||||
|
||||
let icchashtbl_replace n =
|
||||
let h = ICCHashtbl.create 50 in
|
||||
for i = 0 to n do
|
||||
|
|
@ -319,11 +337,10 @@ module Tbl = struct
|
|||
"ihashtbl_replace", (fun n -> ignore (ihashtbl_replace n)), n;
|
||||
"ipersistenthashtbl_replace", (fun n -> ignore (ipersistenthashtbl_replace n)), n;
|
||||
"imap_replace", (fun n -> ignore (imap_replace n)), n;
|
||||
"intmap_replace", (fun n -> ignore (intmap_replace n)), n;
|
||||
"ccflathashtbl_replace", (fun n -> ignore (icchashtbl_replace n)), n;
|
||||
]
|
||||
|
||||
let my_len = 250
|
||||
|
||||
let phashtbl_find h =
|
||||
fun n ->
|
||||
for i = 0 to n-1 do
|
||||
|
|
@ -366,6 +383,12 @@ module Tbl = struct
|
|||
ignore (IMap.find i m);
|
||||
done
|
||||
|
||||
let intmap_find m =
|
||||
fun n ->
|
||||
for i = 0 to n-1 do
|
||||
ignore (CCIntMap.find i m);
|
||||
done
|
||||
|
||||
let icchashtbl_find m =
|
||||
fun n ->
|
||||
for i = 0 to n-1 do
|
||||
|
|
@ -380,6 +403,7 @@ module Tbl = struct
|
|||
let a = Array.init n string_of_int in
|
||||
let pa = CCPersistentArray.init n string_of_int in
|
||||
let m = imap_add n in
|
||||
let m' = intmap_add n in
|
||||
let h'''''' = icchashtbl_add n in
|
||||
B.throughputN 3 [
|
||||
"phashtbl_find", (fun () -> phashtbl_find h n), ();
|
||||
|
|
@ -389,6 +413,7 @@ module Tbl = struct
|
|||
"array_find", (fun () -> array_find a n), ();
|
||||
"persistent_array_find", (fun () -> persistent_array_find pa n), ();
|
||||
"imap_find", (fun () -> imap_find m n), ();
|
||||
"intmap_find", (fun () -> intmap_find m' n), ();
|
||||
"cchashtbl_find", (fun () -> icchashtbl_find h'''''' n), ();
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue