summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Glondu <steph@glondu.net>2020-08-25 07:01:56 +0200
committerStephane Glondu <steph@glondu.net>2020-08-25 07:01:56 +0200
commite904bbfcb2ac82d3d69757bdc61e2d999556d2e1 (patch)
tree6c321788550f31506c87f406255382e15933e184
parent1ac5c6b84df9ea91545efafdbdd6e8870b117bd0 (diff)
New upstream version 1.6
-rw-r--r--CHANGES.md14
-rw-r--r--README.md19
-rw-r--r--_opam1
-rw-r--r--_tags3
-rw-r--r--appveyor.yml17
-rw-r--r--benchmark.opam10
-rw-r--r--dune-project1
-rw-r--r--examples/ar_ba.ml8
-rw-r--r--examples/composition.ml1
-rw-r--r--examples/dune10
-rw-r--r--examples/jbuild12
-rw-r--r--examples/let_try.ml4
-rw-r--r--examples/match_array.ml4
-rw-r--r--examples/regexps.ml2
-rw-r--r--jbuild7
-rw-r--r--pkg/pkg.ml2
-rw-r--r--src/benchmark.ml (renamed from benchmark.ml)34
-rw-r--r--src/benchmark.mli (renamed from benchmark.mli)6
-rw-r--r--src/dune6
-rw-r--r--tests/dune14
-rw-r--r--tests/jbuild20
-rw-r--r--tests/long_run.ml4
22 files changed, 106 insertions, 93 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 2fb959b..4cd3035 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,9 @@
+1.6 2018-09-07
+--------------
+
+- Port to Dune (not the former Jbuilder) and dune-release.
+- Fix some typos in the documentation.
+
1.5 2018-05-17
--------------
@@ -15,12 +21,12 @@ Very old changes
* benchmark.ml: Code mostly rewritten to improve clarity (and to
correct some bugs). Allows to return multiple times for a given
test. Student's statistical test to determine whether two rates
- are significantly different (see [log_gamma], [betai],
- [cpl_student_t], [comp_rates] and [different_rates]).
+ are significantly different (see `log_gamma`, `betai`,
+ `cpl_student_t`, `comp_rates` and `different_rates`).
* benchmark.mli: The documentation is greatly improved. Functions
- [make], [add], [sub] instead of [create], [sum], [diff] for
- uniformness with the OCaml standard library.
+ `make`, `add`, `sub` instead of `create`, `sum`, `diff` for
+ uniformity with the OCaml standard library.
2004-08-18 Troestler Christophe <chris_77@users.sourceforge.net>
diff --git a/README.md b/README.md
index 25649a3..9a98b6b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
[![Build Status](https://travis-ci.org/Chris00/ocaml-benchmark.svg?branch=master)](https://travis-ci.org/Chris00/ocaml-benchmark)
+[![Build status](https://ci.appveyor.com/api/projects/status/jeyp56227sniv3vo?svg=true)](https://ci.appveyor.com/project/Chris00/ocaml-benchmark)
Benchmark — measure/compare run-time of OCaml functions
=======================================================
@@ -14,13 +15,25 @@ The easier way to install it is by using opam:
opam install benchmark
-If you want to perform this operation manually, see `benchmark.opam`
-for installation instructions.
+If you use the development version of this project, install [Dune][]
+and issue
+ make
+ make install
+[Dune]: https://github.com/ocaml/dune
-Copyright 2004-present, Christophe Troestler
+Documentation
+-------------
+
+See the [interface of `Benchmark`](src/benchmark.mli). It can also be
+read in [HTML](https://chris00.github.io/ocaml-benchmark/doc/).
+
+
+
+
+Copyright 2004-present, Christophe Troestler
Copyright 2002-2003, Doug Bagley
diff --git a/_opam b/_opam
deleted file mode 100644
index f420869..0000000
--- a/_opam
+++ /dev/null
@@ -1 +0,0 @@
-bug-reports: "https://github.com/Chris00/ocaml-benchmark/issues"
diff --git a/_tags b/_tags
deleted file mode 100644
index f6154c8..0000000
--- a/_tags
+++ /dev/null
@@ -1,3 +0,0 @@
-# OASIS_START
-# OASIS_STOP
-true: strict_formats, safe_string
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..5cdfa85
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,17 @@
+platform:
+ - x64
+
+environment:
+ global:
+ FORK_USER: ocaml
+ FORK_BRANCH: master
+ CYG_ROOT: C:\cygwin64
+ matrix:
+ - OPAM_SWITCH: 4.06.1+mingw64c
+ - OPAM_SWITCH: 4.06.1+msvc64c
+
+install:
+ - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/$env:FORK_USER/ocaml-ci-scripts/$env:FORK_BRANCH/appveyor-install.ps1"))
+
+build_script:
+ - call %CYG_ROOT%\bin\bash.exe -l %APPVEYOR_BUILD_FOLDER%\appveyor-opam.sh
diff --git a/benchmark.opam b/benchmark.opam
index 4748f53..e9bc954 100644
--- a/benchmark.opam
+++ b/benchmark.opam
@@ -1,4 +1,4 @@
-version: "1.5"
+version: "1.6"
opam-version: "1.2"
maintainer: "Christophe Troestler <Christophe.Troestler@umons.ac.be>"
authors: ["Christophe Troestler <Christophe.Troestler@umons.ac.be>"
@@ -10,13 +10,11 @@ dev-repo: "https://github.com/Chris00/ocaml-benchmark.git"
bug-reports: "https://github.com/Chris00/ocaml-benchmark/issues"
doc: "https://Chris00.github.io/ocaml-benchmark/doc"
build: [
- [ "jbuilder" "subst" ] {pinned}
- [ "jbuilder" "build" "-p" name "-j" jobs ]
+ [ "dune" "subst" ] {pinned}
+ [ "dune" "build" "-p" name "-j" jobs ]
]
depends: [
- "jbuilder" {build}
+ "dune" {build}
"base-unix"
- "base-bigarray" {test}
- "pcre" {test}
]
available: [ ocaml-version >= "3.12.0" ]
diff --git a/dune-project b/dune-project
new file mode 100644
index 0000000..7655de0
--- /dev/null
+++ b/dune-project
@@ -0,0 +1 @@
+(lang dune 1.1)
diff --git a/examples/ar_ba.ml b/examples/ar_ba.ml
index ada1343..9a82f04 100644
--- a/examples/ar_ba.ml
+++ b/examples/ar_ba.ml
@@ -32,7 +32,7 @@ let ba_alloc () =
let a = Array1.create float64 c_layout n in
Array1.fill a 1.;
let s = ref 0. in
- for j = 1 to m do
+ for _ = 1 to m do
for i = 0 to n-1 do s := !s +. a.{i} done
done
@@ -40,7 +40,7 @@ let set_ba (a: vec) = for i = 0 to n-1 do a.{i} <- 1. done
let set_ba_alloc () =
let a = Array1.create float64 c_layout n in
- for j = 1 to m do
+ for _ = 1 to m do
for i = 0 to n-1 do a.{i} <- 3. done
done
@@ -63,7 +63,7 @@ let arr_cl () =
let arr_alloc () =
let b = Array.make n 1. in
let s = ref 0. in
- for j = 1 to m do
+ for _ = 1 to m do
for i = 0 to n-1 do s := !s +. b.(i) done
done
@@ -71,7 +71,7 @@ let set_arr (b: float array) = for i = 0 to n-1 do b.(i) <- 1. done
let set_arr_alloc () =
let a = Array.make n 0. in
- for j = 1 to m do
+ for _ = 1 to m do
for i = 0 to n-1 do a.(i) <- 3. done
done
diff --git a/examples/composition.ml b/examples/composition.ml
index bd1fdcd..55025f6 100644
--- a/examples/composition.ml
+++ b/examples/composition.ml
@@ -12,7 +12,6 @@ let splice l i j = fun k ->
open Benchmark
-open Printf
let ncomp = 400 (* Number of compositions *)
diff --git a/examples/dune b/examples/dune
new file mode 100644
index 0000000..99911b9
--- /dev/null
+++ b/examples/dune
@@ -0,0 +1,10 @@
+
+(executables
+ (names ar_ba composition iter let_try loops
+ match_array numbers regexps try_if func_record)
+ (libraries benchmark bigarray str pcre))
+
+(alias
+ (name examples)
+ (deps ar_ba.exe composition.exe iter.exe let_try.exe loops.exe
+ match_array.exe numbers.exe regexps.exe try_if.exe func_record.exe))
diff --git a/examples/jbuild b/examples/jbuild
deleted file mode 100644
index 87973f1..0000000
--- a/examples/jbuild
+++ /dev/null
@@ -1,12 +0,0 @@
-(jbuild_version 1)
-
-(executables
- ((names (ar_ba composition iter let_try loops
- match_array numbers regexps try_if func_record))
- (libraries (benchmark bigarray str pcre))))
-
-
-(alias
- ((name examples)
- (deps (ar_ba.exe composition.exe iter.exe let_try.exe loops.exe
- match_array.exe numbers.exe regexps.exe try_if.exe func_record.exe))))
diff --git a/examples/let_try.ml b/examples/let_try.ml
index 11100d9..e2df919 100644
--- a/examples/let_try.ml
+++ b/examples/let_try.ml
@@ -24,7 +24,7 @@ let g a =
open Benchmark
let () =
- let a = Array.init 1000 (fun i -> Random.int 2 - 1) in
+ let a = Array.init 1000 (fun _ -> Random.int 2 - 1) in
let res = throughputN ~repeat:5 1 [("Some", f, a);
- ("()->", g, a); ] in
+ ("()->", g, a); ] in
tabulate res
diff --git a/examples/match_array.ml b/examples/match_array.ml
index e13a7b4..87d3379 100644
--- a/examples/match_array.ml
+++ b/examples/match_array.ml
@@ -10,7 +10,7 @@ let string_of_month1 =
fun i -> Array.unsafe_get month i
let f1 () =
- for i = 1 to n do ignore(string_of_month1 7) done
+ for _ = 1 to n do ignore(string_of_month1 7) done
let string_of_month2 = function
| 0 -> "Jan"
@@ -28,7 +28,7 @@ let string_of_month2 = function
| _ -> failwith "h"
let f2 () =
- for i = 1 to n do ignore(string_of_month2 7) done
+ for _ = 1 to n do ignore(string_of_month2 7) done
open Benchmark
diff --git a/examples/regexps.ml b/examples/regexps.ml
index 8773daf..6c9db01 100644
--- a/examples/regexps.ml
+++ b/examples/regexps.ml
@@ -13,7 +13,7 @@ open Benchmark
let bigdata =
let size = 500000 in
let buf = Buffer.create size in
- for i = 1 to size/10 - 1 do Buffer.add_string buf "012345678 " done;
+ for _ = 1 to size/10 - 1 do Buffer.add_string buf "012345678 " done;
Buffer.add_string buf "0123456789";
Buffer.contents buf
diff --git a/jbuild b/jbuild
deleted file mode 100644
index a1e10b9..0000000
--- a/jbuild
+++ /dev/null
@@ -1,7 +0,0 @@
-(jbuild_version 1)
-
-(library
- ((name benchmark)
- (public_name benchmark)
- (libraries (unix))
- (synopsis "Benchmark running times of code")))
diff --git a/pkg/pkg.ml b/pkg/pkg.ml
deleted file mode 100644
index 1a04c2b..0000000
--- a/pkg/pkg.ml
+++ /dev/null
@@ -1,2 +0,0 @@
-#use "topfind"
-#require "topkg-jbuilder.auto"
diff --git a/benchmark.ml b/src/benchmark.ml
index f0cb975..ab84cff 100644
--- a/benchmark.ml
+++ b/src/benchmark.ml
@@ -152,10 +152,10 @@ let runloop n_iters n f x =
while tbase = (!t0).utime do t0 := make 0L done;
(* Loop over function we are timing [n] times (looping on int64
quantities takes too long, this is why we use composite loops). *)
- for i = 1 to n1 do
- for j = 0 to max_int do ignore(f x) done; (* [max_iter] runs *)
+ for _ = 1 to n1 do
+ for _ = 0 to max_int do ignore(f x) done; (* [max_iter] runs *)
done;
- for i = 1 to n0 do ignore(f x) done;
+ for _ = 1 to n0 do ignore(f x) done;
let t1 = make n_iters in
pos_sub t1 !t0
@@ -186,7 +186,7 @@ let print_run out ?(min_count=4L) ?(min_cpu=0.4) ~style ?fwidth ?fdigits b =
let latency n out ?min_count ?min_cpu ~style ?fwidth ?fdigits
- ~repeat name f x =
+ ~repeat _name f x =
let rec loop nrep acc =
if nrep < 1 then acc
else (
@@ -203,7 +203,7 @@ let latency n out ?min_count ?min_cpu ~style ?fwidth ?fdigits
[estimate_niter] estimate by linear interpolation the number of
iter to run [> tmin] and then the test is performed. *)
let throughput tmin out ?min_count ?min_cpu ~style ?fwidth ?fdigits
- ~repeat name f x =
+ ~repeat _name f x =
(* Run [f] for [niter] times and complete with >= [nmin] iterations
(estimated by linear interpolation) to run >= [tmin]. *)
let rec run_test nmin niter bm_init total_wall =
@@ -320,7 +320,7 @@ let testN ~test default_f_name ?min_count ?min_cpu ~style
(name, bm) in
List.map result_of funs
-let rec string_of_names funs =
+let string_of_names funs =
String.concat ", " (List.map (fun (a,_,_) -> sprintf "%S" a) funs)
@@ -405,7 +405,7 @@ let log_gamma =
log(sqrt2pi *. sum c_last xg 0.) +. (x -. 0.5) *. log xg_5 -. xg_5
(* Beta function. It is assumed [a > 0. && b > 0.]. *)
-let beta a b =
+let _beta a b =
assert(a > 0. && b > 0.);
exp(log_gamma a +. log_gamma b -. log_gamma(a +. b))
@@ -572,7 +572,7 @@ let tabulate ?(no_parent=false) ?(confidence=0.95) results =
col_width.(1) <- max (String.length ra) col_width.(1);
col_width.(2) <- max (String.length ra_err) col_width.(2);
(* Columns 3..(len + 2): performance ratios *)
- let make_col j (col_name, col_n, col_rate, col_s) =
+ let make_col j (_col_name, col_n, col_rate, col_s) =
let ratio =
if i = j || is_nan row_rate || is_nan col_rate then "--" else
let p = 100. *. row_rate /. col_rate -. 100. in
@@ -641,29 +641,24 @@ module Tree = struct
assert (parse_path "foo" = ["foo"]);
assert (parse_path "" = [""])
*)
- let rev_parse_path check_name s =
+ let rev_parse_path s =
let l = ref [] in
let i0 = ref 0 in
for i = 0 to String.length s - 1 do
if String.unsafe_get s i = '.' then (
let name = String.sub s !i0 (i - !i0) in
- check_name name;
l := name :: !l;
i0 := i + 1;
)
done;
let name = if !i0 = 0 then s
else String.sub s !i0 (String.length s - !i0) in
- check_name name;
name :: !l
let check_reserved name =
if name = "*" then invalid_arg "Name \"*\" is reserved for wildcard"
- let check_nothing _ = ()
-
- let parse_path s =
- List.rev(rev_parse_path check_nothing s)
+ let parse_path s = List.rev(rev_parse_path s)
(** {2 Bench Tree} *)
@@ -709,7 +704,7 @@ module Tree = struct
let concat l = List.fold_left merge empty l
let check_allowed_name n =
- if n = "*" then invalid_arg "Name \"*\" is reserved for wildcard";
+ check_reserved n;
for i = 0 to String.length n - 1 do
if String.unsafe_get n i = '.' then
invalid_arg "Names cannot contain dots"
@@ -720,17 +715,16 @@ module Tree = struct
let name_nonempty t n = Tree(None, SMap.singleton n t)
let name t n =
- (* Assume the name [n] is valid *)
+ check_allowed_name n;
if n = "" then t else name_nonempty t n
(* prefix a tree with a path. Now the whole tree is only reachable
from this given path *)
let prefix path t =
- List.fold_right (fun n t -> check_reserved n; name t n) path t
+ List.fold_right (fun n t -> name t n) path t
let ( @>> ) n t =
- let path = rev_parse_path check_reserved n in
- List.fold_left name t path
+ List.fold_left name t (rev_parse_path n)
let ( @> ) name bench = name @>> (of_bench bench)
diff --git a/benchmark.mli b/src/benchmark.mli
index 3c2af2c..b852394 100644
--- a/benchmark.mli
+++ b/src/benchmark.mli
@@ -262,7 +262,7 @@ module Tree : sig
]} *)
val ( @>> ) : string -> t -> t
- (** [name >:: tree] makes [tree] accessible through the given
+ (** [name @>> tree] makes [tree] accessible through the given
[name], i.e., prefix all paths in the tree by [name]. It has no
effect if [name = ""]. If the name contains dots, it is
interpreted as a path. For instance ["n1.n2" @>> tree] is
@@ -281,7 +281,7 @@ module Tree : sig
will give the tree [{a.(b, b.d, c, d}, d}]. *)
val ( @>>> ) : string -> t list -> t
- (** [name @>>> l] is equivalent to [name >:: concat l]. It names a list of
+ (** [name @>>> l] is equivalent to [name @>> concat l]. It names a list of
trees, and is useful to build lists of benchmarks related to some
common topic. If the name contains dots, it is interpreted
as a path.
@@ -310,7 +310,7 @@ module Tree : sig
val prefix : path -> t -> t
(** Add the path as a prefix to the tree, similar to repeated
- calls to [>::]. *)
+ calls to [@>>]. *)
val filter : path -> t -> t
(** [filter p t] return the tree obtained by keeping all the paths
diff --git a/src/dune b/src/dune
new file mode 100644
index 0000000..1dfffb8
--- /dev/null
+++ b/src/dune
@@ -0,0 +1,6 @@
+
+(library
+ (name benchmark)
+ (public_name benchmark)
+ (libraries unix)
+ (synopsis "Benchmark running times of code"))
diff --git a/tests/dune b/tests/dune
new file mode 100644
index 0000000..d26bef9
--- /dev/null
+++ b/tests/dune
@@ -0,0 +1,14 @@
+(executables
+ (names long_run tree)
+ (libraries benchmark unix))
+
+(alias
+ (name tests)
+ (deps long_run.exe tree.exe))
+
+(alias
+ (name runtest)
+ (deps long_run.exe tree.exe)
+ (action (progn
+ (run %{dep:long_run.exe})
+ (run %{dep:tree.exe}))))
diff --git a/tests/jbuild b/tests/jbuild
deleted file mode 100644
index 8ce9a9a..0000000
--- a/tests/jbuild
+++ /dev/null
@@ -1,20 +0,0 @@
-(jbuild_version 1)
-
-(executables
- ((names (long_run tree))
- (libraries (benchmark unix))))
-
-
-(alias
- ((name tests)
- (deps (long_run.exe tree.exe))))
-
-(alias
- ((name runtest)
- (deps (long_run.exe))
- (action (run ${<}))))
-
-(alias
- ((name runtest)
- (deps (tree.exe))
- (action (run ${<}))))
diff --git a/tests/long_run.ml b/tests/long_run.ml
index db71d83..6ac5d74 100644
--- a/tests/long_run.ml
+++ b/tests/long_run.ml
@@ -5,8 +5,8 @@ open Benchmark
let long () =
let s = ref 0. in
- for i = 1 to 100_000 do
- for j = 1 to 2_000 do
+ for _ = 1 to 100_000 do
+ for _ = 1 to 2_000 do
s := !s +. 1.
done
done