From c91003f10ef5dfecd9f9baf4d178c62db1a3fd12 Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Tue, 16 Apr 2024 20:17:07 +0300 Subject: [PATCH] Use `replace` instead of `add` This is more in line with with other benchmarks of hash tables --- bench/bench_hashtbl.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bench/bench_hashtbl.ml b/bench/bench_hashtbl.ml index 446f566..0119cb3 100644 --- a/bench/bench_hashtbl.ml +++ b/bench/bench_hashtbl.ml @@ -23,7 +23,7 @@ let run_one_domain ~budgetf ?(n_ops = 400 * Util.iter_factor) ?(n_keys = 1000) for _ = 1 to n_keys do let value = Random.bits () in let key = value mod n_keys in - Htbl.add t key value + Htbl.replace t key value done; let n_ops = (100 + percent_mem) * n_ops / 100 in @@ -50,7 +50,7 @@ let run_one_domain ~budgetf ?(n_ops = 400 * Util.iter_factor) ?(n_keys = 1000) loop (n - 1) end else if op < limit_add then begin - Htbl.add t key value; + Htbl.replace t key value; loop (n - 1) end else begin @@ -85,7 +85,7 @@ let run_one ~budgetf ~n_domains ?(n_ops = 400 * Util.iter_factor) for _ = 1 to n_keys do let value = Random.bits () in let key = value mod n_keys in - Htbl.add t key value + Htbl.replace t key value done; let n_ops = (100 + percent_mem) * n_ops / 100 in @@ -115,7 +115,7 @@ let run_one ~budgetf ~n_domains ?(n_ops = 400 * Util.iter_factor) end else if op < limit_add then begin Mutex.lock mutex; - Htbl.add t key value; + Htbl.replace t key value; Mutex.unlock mutex; loop (n - 1) end