Skip to content

Commit 55c6228

Browse files
OlivierNicolehhugo
andauthored
Add benchmarking suite targeting current-bench (#1860)
* Add benchmark suite for current-bench --------- Co-authored-by: Hugo Heuzard <[email protected]>
1 parent c5d39ce commit 55c6228

File tree

7 files changed

+46
-6
lines changed

7 files changed

+46
-6
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ installdoc:
4040
git worktree add _wikidoc origin/wikidoc
4141
rsync -av doc-dev/ _wikidoc/doc/dev/
4242

43-
.PHONY: all tests tests-wasm test runtest runtests doc clean installdoc
43+
bench:
44+
$(MAKE) -C benchmarks bench
45+
46+
.PHONY: all tests tests-wasm test runtest runtests doc clean installdoc bench

bench.Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM ocaml/opam:debian-ocaml-5.3
2+
WORKDIR /bench-dir
3+
RUN sudo apt-get update && \
4+
sudo apt-get install -qq -yy --no-install-recommends pkg-config libgmp-dev \
5+
wget
6+
RUN sudo ln -sf /usr/bin/opam-2.3 /usr/bin/opam
7+
RUN opam remote add origin https://github.com/ocaml/opam-repository.git && \
8+
opam update
9+
RUN wget https://nodejs.org/dist/v22.14.0/node-v22.14.0-linux-x64.tar.xz && \
10+
tar xJvf node-v22.14.0-linux-x64.tar.xz
11+
ENV PATH="/bench-dir/node-v22.14.0-linux-x64/bin:$PATH"
12+
RUN wget https://github.com/WebAssembly/binaryen/releases/download/version_122/binaryen-version_122-x86_64-linux.tar.gz && \
13+
tar xzvf binaryen-version_122-x86_64-linux.tar.gz
14+
ENV PATH="/bench-dir/binaryen-version_122/bin:$PATH"
15+
RUN opam install --fake binaryen-bin
16+
COPY --chown=opam:opam ./*.opam ./
17+
RUN opam pin -yn --with-version=dev .
18+
RUN opam install -y --deps-only js_of_ocaml-compiler
19+
COPY --chown=opam:opam . ./
20+
RUN opam install -y wasm_of_ocaml-compiler
21+
WORKDIR ./benchmarks

benchmarks/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ GRAPHSEFF = time-effects.pdf size-effects.pdf size-bzip2-effects.pdf
1010
# For full benchs:
1111
all: _perf graphsnopr graphspr graphseff _noperf
1212

13+
# This target is the one run by `current-bench`,
14+
# see https://github.com/ocurrent/current-bench
15+
.PHONY: bench
16+
bench:
17+
make _noprecomp
18+
$(RUN) ./report-wasm-cb.config ./report-jsoo-cb.config
19+
$(REPORT) -format current-bench -config report-wasm-cb.config \
20+
-ylabel "Wasm_of_ocaml"
21+
$(REPORT) -format current-bench -config report-jsoo-cb.config \
22+
-ylabel "Js_of_ocaml"
23+
24+
1325
graphsnopr: _noprecomp $(GRAPHSNOPR)
1426

1527
graphspr: __precomp $(GRAPHSPR)

benchmarks/report-jsoo-cb.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
histogramref times node js_of_ocaml #fbaf4f node
2+
histogram sizes "" js_of_ocaml/gzipped #ffffff Size (gzipped)

benchmarks/report-wasm-cb.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
histogram times node wasm_of_ocaml #ffffff node
2+
histogram sizes "" wasm_of_ocaml/gzipped #ffffff Generated Wasm (gzipped)

benchmarks/run.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ let file_size ?(wasm = false) param =
153153
let files =
154154
if wasm then src ^ " " ^ Filename.remove_extension src ^ ".assets/*" else src
155155
in
156-
Format.sprintf "wc -c --total only %s > %s" files dst)
156+
Format.sprintf "cat %s | wc -c > %s" files dst)
157157

158158
let compr_file_size ?(wasm = false) param =
159159
compile_no_ext param ~comptime:false (fun ~src ~dst ->

benchmarks/sources/ml/splay.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ let random =
191191
| 31 | 32 -> -1
192192
| _ -> int_of_string "0xffffffff"
193193
in
194-
let l_0xc761c23c = int_of_string "0xc761c23c" in
195-
let l_0xd3a2646c = int_of_string "0xd3a2646c" in
196-
let l_0xfd7046c5 = int_of_string "0xfd7046c5" in
197-
let l_0xb55a4f09 = int_of_string "0xb55a4f09" in
194+
let l_0xc761c23c = Int64.of_string "0xc761c23c" |> Int64.to_int in
195+
let l_0xd3a2646c = Int64.of_string "0xd3a2646c" |> Int64.to_int in
196+
let l_0xfd7046c5 = Int64.of_string "0xfd7046c5" |> Int64.to_int in
197+
let l_0xb55a4f09 = Int64.of_string "0xb55a4f09" |> Int64.to_int in
198198
fun () ->
199199
(* // Robert Jenkins' 32 bit integer hash function. *)
200200
let s = !seed in

0 commit comments

Comments
 (0)