test: improve perf by changing random gens

This commit is contained in:
Simon Cruanes 2018-10-13 18:52:22 -05:00
parent e22a55668d
commit 2a9795090b
5 changed files with 11 additions and 12 deletions

View file

@ -170,7 +170,7 @@ let sort_indices cmp a =
*) *)
(*$Q (*$Q
Q.(array printable_string) (fun a -> \ Q.(array_of_size Gen.(0 -- 30) printable_string) (fun a -> \
let b = sort_indices String.compare a in \ let b = sort_indices String.compare a in \
sorted String.compare a = Array.map (Array.get a) b) sorted String.compare a = Array.map (Array.get a) b)
*) *)
@ -485,7 +485,7 @@ let swap a i j =
*) *)
(*$QR (*$QR
Q.(array small_int) (fun a -> Q.(array_of_size Gen.(0 -- 100) small_int) (fun a ->
let b = Array.copy a in let b = Array.copy a in
for i = 0 to Array.length a-1 do for i = 0 to Array.length a-1 do
for j = i+1 to Array.length a-1 do for j = i+1 to Array.length a-1 do

View file

@ -68,8 +68,7 @@
assert_equal ~printer:Q.Print.(list int) l l' assert_equal ~printer:Q.Print.(list int) l l'
in in
test 100_000; test 300_000;
test 400_000;
*) *)

View file

@ -918,7 +918,7 @@ let unlines_gen g =
*) *)
(*$Q (*$Q
Q.(list string) (fun l -> \ Q.(small_list small_string) (fun l -> \
let l = unlines l |> lines in \ let l = unlines l |> lines in \
l = (unlines l |> lines)) l = (unlines l |> lines))
*) *)

View file

@ -263,13 +263,13 @@ let of_string s = if is_valid s then Some s else None
*) *)
(*$QR (*$QR
Q.string (fun s -> Q.small_string (fun s ->
Q.assume (CCString.for_all (fun c -> Char.code c < 128) s); Q.assume (CCString.for_all (fun c -> Char.code c < 128) s);
is_valid s) is_valid s)
*) *)
(*$QR & ~long_factor:10 (*$QR & ~long_factor:10
Q.string (fun s -> Q.small_string (fun s ->
Q.assume (CCString.for_all (fun c -> Char.code c < 128) s); Q.assume (CCString.for_all (fun c -> Char.code c < 128) s);
s = (of_string_exn s |> to_seq |> of_seq |> to_string) s = (of_string_exn s |> to_seq |> of_seq |> to_string)
) )
@ -312,8 +312,8 @@ let of_string s = if is_valid s then Some s else None
(* compare with uutf *) (* compare with uutf *)
(*$QR & ~long_factor:40 ~count:100_000 (*$QR & ~long_factor:40 ~count:50_000
Q.string (fun s -> Q.small_string (fun s ->
let v1 = is_valid s in let v1 = is_valid s in
let v2 = uutf_is_valid s in let v2 = uutf_is_valid s in
if v1=v2 then true if v1=v2 then true
@ -321,8 +321,8 @@ let of_string s = if is_valid s then Some s else None
) )
*) *)
(*$QR & ~long_factor:40 ~count:100_000 (*$QR & ~long_factor:40 ~count:50_000
Q.string (fun s -> Q.small_string (fun s ->
Q.assume (is_valid s && uutf_is_valid s); Q.assume (is_valid s && uutf_is_valid s);
let pp s = Q.Print.(list pp_uchar) s in let pp s = Q.Print.(list pp_uchar) s in
let l_uutf = uutf_to_seq s |> Sequence.to_list in let l_uutf = uutf_to_seq s |> Sequence.to_list in

View file

@ -744,7 +744,7 @@ module Make(Elt:sig
~print:str_of_op ~print:str_of_op
gen_op gen_op
let arb_ops = Q.list arb_op let arb_ops = Q.list_of_size Q.Gen.(0 -- 20) arb_op
module L_impl = struct module L_impl = struct
type t = { type t = {