Skip to content

Commit

Permalink
Switch STM.arb_cmds to use an exponential distribution, avoiding list…
Browse files Browse the repository at this point in the history
…s of 10000 cmds
  • Loading branch information
jmid committed Sep 3, 2024
1 parent 185d35f commit 2f196e8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/STM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,14 @@ struct

let gen_cmds_size gen s size_gen = Gen.sized_size size_gen (gen_cmds gen s)

let exp_dist_gen =
let mean = 10. in
let skew = 0.75 in (* to avoid too many empty cmd lists *)
let unit_gen = Gen.float_bound_inclusive 1.0 in
Gen.map (fun p -> int_of_float (-. (mean *. (log p)) +. skew)) unit_gen

let arb_cmds s =
let cmds_gen = Gen.sized (gen_cmds Spec.arb_cmd s) in
let cmds_gen = gen_cmds_size Spec.arb_cmd s exp_dist_gen in
let shrinker = shrink_list ?shrink:(Spec.arb_cmd s).shrink in (* pass opt. elem. shrinker *)
let ac = QCheck.make ~shrink:(Shrink.filter (cmds_ok Spec.init_state) shrinker) cmds_gen in
(match (Spec.arb_cmd s).print with
Expand Down

0 comments on commit 2f196e8

Please sign in to comment.