Skip to content

Commit

Permalink
Add skiplist with generalized size computation
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Dec 23, 2023
1 parent 08e5e60 commit 5114f01
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 260 deletions.
6 changes: 3 additions & 3 deletions bench/bench_skiplist.ml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
open Saturn

let workload num_elems num_threads add remove =
let sl = Skiplist.create () in
let sl = Skiplist.create ~compare:Int.compare () in
let elems = Array.init num_elems (fun _ -> Random.int 10000) in
let push () =
Domain.spawn (fun () ->
let start_time = Unix.gettimeofday () in
for i = 0 to (num_elems - 1) / num_threads do
Domain.cpu_relax ();
let prob = Random.float 1.0 in
if prob < add then Skiplist.add sl (Random.int 10000) |> ignore
if prob < add then Skiplist.try_add sl (Random.int 10000) () |> ignore
else if prob >= add && prob < add +. remove then
Skiplist.remove sl (Random.int 10000) |> ignore
Skiplist.try_remove sl (Random.int 10000) |> ignore
else Skiplist.mem sl elems.(i) |> ignore
done;
start_time)
Expand Down
Loading

0 comments on commit 5114f01

Please sign in to comment.