Skip to content

Commit

Permalink
Use replace instead of add
Browse files Browse the repository at this point in the history
This is more in line with with other benchmarks of hash tables
  • Loading branch information
polytypic committed Apr 16, 2024
1 parent 81746e1 commit c91003f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bench/bench_hashtbl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c91003f

Please sign in to comment.