Skip to content

Commit 341f457

Browse files
S41dfilipeom
authored andcommitted
fix cache hits test
1 parent a761930 commit 341f457

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ module Z3 :
143143
val get_sat_model :
144144
?symbols:Symbol.t list ->
145145
t -> Expr.Set.t -> [ `Model of Model.t | `Unknown | `Unsat ]
146-
val cache_hits : unit -> int
147-
val cache_misses : unit -> int
148146
end
149147
# let solver = Z3.create ();;
150148
val solver : Z3.t = <abstr>

doc/index.mld

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ module Z3 :
5252
?symbols:Smtml.Symbol.t list ->
5353
t ->
5454
Smtml.Expr.Set.t -> [ `Model of Smtml.Model.t | `Unknown | `Unsat ]
55-
val cache_hits : unit -> int
56-
val cache_misses : unit -> int
5755
end
5856
# let solver = Z3.create ();;
5957
val solver : Z3.t = <abstr>

src/smtml/altergo_mappings.default.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ module M = struct
224224
let interrupt _ =
225225
Fmt.failwith "Altergo_mappings: interrupt is not implemented"
226226

227-
let get_statistics _ =
228-
Fmt.failwith "Altergo_mappings: get_statistics is not implemented"
227+
let get_statistics _ = Statistics.Map.empty
229228

230229
let pp_statistics _fmt _solver = ()
231230
end

src/smtml/bitwuzla_mappings.default.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,7 @@ module Fresh_bitwuzla (B : Bitwuzla_cxx.S) : M = struct
552552
(* does nothing *)
553553
()
554554

555-
let get_statistics _ =
556-
Fmt.failwith "Bitwuzla_mappings: Solver.get_statistics not implemented"
555+
let get_statistics _ = Statistics.Map.empty
557556

558557
let pp_statistics fmt solver = Solver.pp_statistics fmt solver
559558
end

src/smtml/colibri2_mappings.default.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ module M = struct
206206

207207
let interrupt _ = ()
208208

209-
let get_statistics _ =
210-
Fmt.failwith "Colibri2_mappings: Solver.get_statistics not implemented"
209+
let get_statistics _ = Statistics.Map.empty
211210

212211
let pp_statistics _fmt _solver = ()
213212
end

src/smtml/cvc5_mappings.default.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,9 @@ module Fresh_cvc5 () = struct
561561

562562
let interrupt _ = ()
563563

564-
let get_statistics _ =
565-
Fmt.failwith "Cvc5_mappings: Solver.get_statistics not implemented!"
564+
let get_statistics _ = Statistics.Map.empty
566565

567-
let pp_statistics _ =
568-
Fmt.failwith "Cvc5_mappings: Solver.pp_statistics not implemented!"
566+
let pp_statistics _ _ = ()
569567
end
570568

571569
(* Not supported *)

test/integration/test_solver.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,20 @@ module Make (M : Mappings_intf.S_with_fresh) = struct
4444
let solver = Cached.create ~logic:LIA () in
4545
let x = Infix.symbol "x" Ty_int in
4646
let c = Infix.(Int.(x >= int 0)) in
47-
assert (Cached.cache_hits () = 0);
47+
let get_stat key =
48+
let stats = Cached.get_statistics solver in
49+
let stat = Statistics.Map.find_opt key stats in
50+
match stat with
51+
(* we're using this for cache hitrate so it's always `Int *)
52+
| Some (`Int s) -> s
53+
| _ -> Fmt.failwith "%s should exist and be an int in stats" key
54+
in
55+
assert (get_stat "cache hits" = 0);
4856
assert_sat (Cached.check_set solver @@ Expr.Set.singleton c);
4957
assert_sat (Cached.check_set solver @@ Expr.Set.singleton c);
5058
assert_sat (Cached.check_set solver @@ Expr.Set.singleton c);
51-
assert (Cached.cache_misses () = 1);
52-
assert (Cached.cache_hits () = 2)
59+
assert (get_stat "cache misses" = 1);
60+
assert (get_stat "cache hits" = 2)
5361

5462
let test_cache_get_model _ =
5563
let open Infix in

0 commit comments

Comments
 (0)