Skip to content

Commit 5407124

Browse files
committed
Benchmarks: Bonsai's partial render table
1 parent 967aaf6 commit 5407124

File tree

5 files changed

+70
-2
lines changed

5 files changed

+70
-2
lines changed

bench.Dockerfile

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ocaml/opam:debian-ocaml-5.3
1+
FROM ocaml/opam:debian-ocaml-5.2
22
WORKDIR /bench-dir
33

44
RUN sudo apt-get update \
@@ -24,6 +24,14 @@ RUN curl -Lq https://github.com/WebAssembly/binaryen/releases/download/$BINARYEN
2424
ENV PATH="/bench-dir/$BINARYEN/bin:$PATH"
2525
RUN opam install --fake binaryen-bin
2626

27+
# Jane Street opam packages
28+
RUN mkdir janestreet \
29+
&& cd janestreet \
30+
&& git clone --depth 20 https://github.com/janestreet/opam-repository \
31+
&& cd opam-repository \
32+
&& git checkout 41c89c7824533f6b63cc5b6d75e6ddb1441d1520 \
33+
&& opam remote add js .
34+
2735
# Install dependencies
2836
COPY --chown=opam:opam ./*.opam ./
2937
RUN opam pin -yn --with-version=dev .
@@ -33,4 +41,12 @@ RUN opam install -y --deps-only js_of_ocaml-compiler
3341
COPY --chown=opam:opam . ./
3442
RUN opam install -y wasm_of_ocaml-compiler
3543

44+
# Compile partial render table benchmark
45+
RUN opam install opam-format stringext uucp cstruct
46+
RUN opam exec -- dune exec tools/ci_setup.exe janestreet .
47+
RUN cd janestreet/lib/bonsai_web_components && git config pull.rebase true && git pull
48+
RUN eval $(opam env) \
49+
&& dune build --root janestreet --profile release lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.wasm.js lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.js
50+
RUN cp -r janestreet/_build/default/lib/bonsai_web_components/partial_render_table/bench/bin/main.bc.* ./benchmarks/benchmark-partial-render-table
51+
3652
WORKDIR ./benchmarks

benchmarks/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bench:
1717
$(MAKE) microbenchmarks
1818
$(MAKE) -C benchmark-fiat-crypto bench
1919
$(MAKE) -C benchmark-ocamlc bench
20+
$(MAKE) -C benchmark-partial-render-table bench
2021

2122
microbenchmarks:
2223
make _noprecomp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.PHONY: bench perform
2+
3+
export NAME=Partial Render Table
4+
5+
SHELL=/bin/bash -o pipefail
6+
7+
bench:
8+
$(MAKE) perform COMPILER=Js_of_ocaml SCRIPT=main.bc.js
9+
$(MAKE) perform COMPILER=Wasm_of_ocaml SCRIPT=main.bc.wasm.js
10+
11+
perform:
12+
node $(SCRIPT) | \
13+
tee /dev/stderr | \
14+
ocaml -I +str str.cma summarize_results.ml $(COMPILER)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
let delim = Str.regexp_string ""
2+
3+
let geometric_mean l =
4+
exp (List.fold_left ( +. ) 0. (List.map log l) /. float (List.length l))
5+
6+
let parse s =
7+
Scanf.sscanf (String.trim s) "%f%s"
8+
@@ fun f u ->
9+
match u with
10+
| "ns" -> f *. 1e-6
11+
| "us" -> f *. 1e-3
12+
| "ms" -> f
13+
| "s" -> f *. 1e3
14+
| _ -> assert false
15+
16+
let () =
17+
let measures = ref [] in
18+
(try
19+
while true do
20+
let l = read_line () in
21+
if String.starts_with ~prefix:"" l
22+
then
23+
let l = read_line () |> Str.split delim |> List.tl |> List.map parse in
24+
measures := l @ !measures
25+
done
26+
with End_of_file -> ());
27+
Format.printf
28+
{|{ "name": "%s",
29+
"results":
30+
[ { "name": "Partial Render Table",
31+
"metrics":
32+
[ { "name": "Execution time (geometric mean)",
33+
"units": "ms",
34+
"value": %f } ] } ] }@.|}
35+
Sys.argv.(1)
36+
(geometric_mean !measures)

tools/ci_setup.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let jane_root, wasmoo_root =
99

1010
let repo = Filename.concat jane_root "opam-repository/packages"
1111

12-
let roots = [ "bonsai_web_components"; "string_dict"; "ppx_html" ]
12+
let roots = [ "bonsai_web_components"; "string_dict"; "ppx_html"; "bonsai_bench" ]
1313

1414
let omitted_others =
1515
StringSet.of_list
@@ -33,6 +33,7 @@ let forked_packages =
3333
; "base"
3434
; "base_bigstring"
3535
; "bin_prot"
36+
; "bonsai"
3637
; "bonsai_test"
3738
; "bonsai_web_components"
3839
; "bonsai_web_test"

0 commit comments

Comments
 (0)