mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-18 00:26:41 -05:00
Fix benches
This commit is contained in:
parent
a01a81667b
commit
d15a41fa3f
1 changed files with 7 additions and 7 deletions
|
|
@ -280,7 +280,7 @@ module Arr = struct
|
|||
let a2 = Array.copy a1 in
|
||||
sort_std a1;
|
||||
quicksort ~limit:10 a2;
|
||||
assert (a1 = a2))
|
||||
assert (CCArray.equal CCInt.equal a1 a2))
|
||||
[ 10; 100; 1000]
|
||||
|
||||
let bench_sort ?(time=2) n =
|
||||
|
|
@ -1154,7 +1154,7 @@ module Str = struct
|
|||
and mk_current () = CCString.find_all_l ~sub:needle haystack
|
||||
and mk_current_compiled =
|
||||
let f = CCString.find_all_l ~start:0 ~sub:needle in fun () -> f haystack in
|
||||
assert (mk_naive () = mk_current ());
|
||||
assert (CCList.equal CCInt.equal (mk_naive ()) (mk_current ()));
|
||||
B.throughputN 3 ~repeat
|
||||
[ "naive", mk_naive, ()
|
||||
; "current", mk_current, ()
|
||||
|
|
@ -1168,7 +1168,7 @@ module Str = struct
|
|||
pp_pb needle haystack;
|
||||
let mk_naive () = find_all_l ~sub:needle haystack
|
||||
and mk_current () = CCString.find_all_l ~sub:needle haystack in
|
||||
assert (mk_naive () = mk_current ());
|
||||
assert (CCList.equal CCInt.equal (mk_naive ()) (mk_current ()));
|
||||
B.throughputN 3 ~repeat
|
||||
[ "naive", mk_naive, ()
|
||||
; "current", mk_current, ()
|
||||
|
|
@ -1182,7 +1182,7 @@ module Str = struct
|
|||
let rec same s1 s2 i =
|
||||
if i = String.length s1 then true
|
||||
else (
|
||||
String.unsafe_get s1 i = String.unsafe_get s2 i && same s1 s2 (i+1)
|
||||
CCChar.equal (String.unsafe_get s1 i) (String.unsafe_get s2 i) && same s1 s2 (i+1)
|
||||
)
|
||||
in
|
||||
String.length pre <= String.length s &&
|
||||
|
|
@ -1193,7 +1193,7 @@ module Str = struct
|
|||
begin
|
||||
let i = ref 0 in
|
||||
while !i < String.length pre &&
|
||||
String.unsafe_get s !i = String.unsafe_get pre !i
|
||||
CCChar.equal (String.unsafe_get s !i) (String.unsafe_get pre !i)
|
||||
do incr i done;
|
||||
!i = String.length pre
|
||||
end
|
||||
|
|
@ -1225,7 +1225,7 @@ module Str = struct
|
|||
else
|
||||
let rec loop str p i =
|
||||
if i = len then true
|
||||
else if String.unsafe_get str i <> String.unsafe_get p i then false
|
||||
else if not (CCChar.equal (String.unsafe_get str i) (String.unsafe_get p i)) then false
|
||||
else loop str p (i + 1)
|
||||
in loop str p 0
|
||||
|
||||
|
|
@ -1256,7 +1256,7 @@ module Str = struct
|
|||
Array.iteri
|
||||
(fun i (pre, y) ->
|
||||
let res = f ~pre y in
|
||||
assert (res = output.(i)))
|
||||
assert (CCBool.equal res output.(i)))
|
||||
input
|
||||
in
|
||||
Benchmark.throughputN 3
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue