Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

work-in-progress Dune conversion #1025

Merged
merged 12 commits into from
Feb 18, 2021
Prev Previous commit
Next Next commit
benchsuite: fix more warnings
  • Loading branch information
gasche committed Feb 15, 2021
commit c66640f065f7e45eca47e96be1289d75c7123ff1
16 changes: 8 additions & 8 deletions benchsuite/bench_nreplace.ml
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@
open Batteries
open String

(* The original Batteries String.nreplace *)
let nreplace_orig ~str ~sub ~by =
(* The current Batteries String.nreplace *)
let nreplace_current ~str ~sub ~by =
if sub = "" then invalid_arg "nreplace: cannot replace all empty substrings" ;
let parts = nsplit str ~by:sub in
let parts = BatString.split_on_string str ~by:sub in
String.concat by parts

(* The suggestion from Glyn Webster that started it all.
@@ -123,7 +123,7 @@ let nreplace_madroach ~str ~sub ~by =
and sublen = String.length sub
and bylen = String.length by in

let rec find_simple ~sub ?(pos=0) str =
let find_simple ~sub ?(pos=0) str =
let find pos =
try BatString.find_from str pos sub with
Not_found -> raise BatEnum.No_more_elements
@@ -135,7 +135,7 @@ let nreplace_madroach ~str ~sub ~by =
* skipping overlapping occurrences *)
let todo =
let skip_unto = ref 0 in
find_simple sub str |>
find_simple ~sub str |>
Enum.filter begin function
|i when i < !skip_unto -> false
|i -> skip_unto := i + sublen; true
@@ -286,7 +286,7 @@ let long_text =

let do_bench_for_len length name =
let run rep iters =
for i=1 to iters do
for _i = 1 to iters do
(* "realistic" workload that attempts to exercise all interesting cases *)
let str = sub long_text 0 length in
let str = rep ~str ~sub:"let" ~by:"let there be light" in
@@ -299,7 +299,7 @@ let do_bench_for_len length name =
in

Bench.bench_n [
"orig "^ name, run nreplace_orig ;
"current "^ name, run nreplace_current ;
"glyn "^ name, run nreplace_glyn ;
"rxd "^ name, run nreplace_rxd ;
"thelema "^ name, run nreplace_thelema ;
@@ -314,7 +314,7 @@ let do_bench_for_len length name =
let main =
(* First check that all implementation performs superficialy the same *)
let check ~str ~sub ~by =
let outp = nreplace_orig ~str ~sub ~by in
let outp = nreplace_current ~str ~sub ~by in
List.iter (fun (d,rep) ->
let outp' = rep ~str ~sub ~by in
if outp' <> outp then (
4 changes: 2 additions & 2 deletions benchsuite/bench_num.ml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ let n = 100_000
let test_array = Array.init n (fun _ -> BatRandom.full_range_int ())

let test_f f niters =
for j = 1 to niters do
for _j = 1 to niters do
for i = 1 to n-1 do
let x = test_array.(i-1) in
let y = test_array.(i) in
@@ -19,4 +19,4 @@ let () = Bench.bench_n [
"Specialized", test_f lt1;
"Polymorphic", test_f lt2;
"BatInt.Compare", test_f lt3;
]
] |> Bench.run_outputs
2 changes: 1 addition & 1 deletion benchsuite/bench_set.ml
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ module SetBench (M : sig val input_length : int end) = struct
have comparable performance results. *)
module StdSet = BatSet.Make(struct type t = int let compare = compare end)

module PSet = BatPSet
module PSet = BatSet

let same_elts stdset pset =
BatList.of_enum (StdSet.enum stdset)
4 changes: 2 additions & 2 deletions benchsuite/bitset.ml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ let fill_arr s =
done

let farr n =
let s = Array.create width false in
let s = Array.make width false in
for _a = 1 to n do
fill_arr s;
for _b = 1 to 100 do
@@ -25,7 +25,7 @@ let farr n =
done

let count_arr n =
let s = Array.create width false in
let s = Array.make width false in
for _a = 1 to n do
let count = ref 0 in
fill_arr s;
11 changes: 8 additions & 3 deletions benchsuite/grouping.ml
Original file line number Diff line number Diff line change
@@ -23,8 +23,13 @@ let makeIntervals d =

let g = [1;3;5;9;12;13;14]

let tests = [ "fsharp", makeIntervals 2, g;
"ocaml", make_intervals 2, g;
let repeat f n =
for _i = 1 to n do
ignore (f g)
done

let tests = [ "fsharp", repeat (makeIntervals 2);
"ocaml", repeat (make_intervals 2);
]

let () = Bench.bench tests
let () = Bench.bench_n tests |> Bench.run_outputs