Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bench/replay.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ module Make (Cache : Cachecache.S.Cache with type key = K.t) = struct
+. mtime stats counter (fun _ -> ignore (Cache.find_opt cache k));
stats.find <- stats.find + 1
| Mem k ->
let b = Cache.mem cache k in
let b = ref false in
stats.mem_span <-
stats.mem_span +. mtime stats counter (fun _ -> ignore b);
if b then stats.hit <- stats.hit + 1
stats.mem_span
+. mtime stats counter (fun _ -> b := Cache.mem cache k);
if !b then stats.hit <- stats.hit + 1
else stats.miss <- stats.miss + 1;
stats.mem <- stats.mem + 1
| _ -> assert false)
Expand All @@ -89,7 +90,7 @@ module Bench_lru = Make (Lru)
module Bench_lfu = Make (Lfu)

let () =
let t = [| 1000; 10000; 100000 |] in
let t = [| 1000; 10000; 100_000 |] in
for _ = 0 to 2 do
for i = 0 to Array.length t - 1 do
Fmt.pr "cap = %d\n" t.(i);
Expand Down
3 changes: 3 additions & 0 deletions src/lfu.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ end) : sig
type key = K.t

val v : int -> 'a t

(*@ t = v c
checks c > 0 *)
val stats : 'a t -> Stats.t
val is_empty : 'a t -> bool
val capacity : 'a t -> int
Expand Down