Skip to content

Commit cf4de97

Browse files
committed
Benchmarks: combined view of both JavaSCript and Wasm
1 parent 6262466 commit cf4de97

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

benchmarks/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ microbenchmarks:
2424
make _noprecomp
2525
$(RUN) ./report-wasm-cb.config ./report-jsoo-cb.config
2626
$(REPORT) -format current-bench -config report-wasm-cb.config \
27-
-ylabel "Wasm_of_ocaml"
27+
-ylabel "Wasm_of_ocaml" | sh utils/aggregate.sh wasm
2828
$(REPORT) -format current-bench -config report-jsoo-cb.config \
29-
-ylabel "Js_of_ocaml"
29+
-ylabel "Js_of_ocaml" | sh utils/aggregate.sh js
3030

3131
graphsnopr: _noprecomp $(GRAPHSNOPR)
3232

benchmarks/benchmark-camlboy/Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ SCRIPT=../../CAMLBOY/_build/default/bin/web/bench_node.bc
88
ROM=../../CAMLBOY/resource/games/tobu.gb
99

1010
bench:
11-
$(MAKE) perform COMPILER=Js_of_ocaml SUFFIX=.js
12-
$(MAKE) perform COMPILER=Wasm_of_ocaml SUFFIX=.wasm.js
11+
$(MAKE) perform COMPILER=Js_of_ocaml SUFFIX=.js KIND=js
12+
$(MAKE) perform COMPILER=Wasm_of_ocaml SUFFIX=.wasm.js KIND=wasm
1313

1414
perform:
1515
node $(SCRIPT)$(SUFFIX) $(ROM) | \
1616
tee /dev/stderr | \
17-
ocaml output_results.ml $(COMPILER)
17+
ocaml output_results.ml $(COMPILER) | \
18+
sh ../utils/aggregate.sh $(KIND)

benchmarks/benchmark-fiat-crypto/Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ export NAME=Fiat-Crypto
55
SHELL=/bin/bash -o pipefail
66

77
bench:
8-
$(MAKE) perform COMPILER=js_of_ocaml EXTRA_ARGS="--enable effects"
9-
$(MAKE) perform COMPILER=wasm_of_ocaml EXTRA_ARGS=""
8+
$(MAKE) perform COMPILER=js_of_ocaml EXTRA_ARGS="--enable effects" KIND=js
9+
$(MAKE) perform COMPILER=wasm_of_ocaml EXTRA_ARGS="" KIND=wasm
1010

1111
perform: bedrock2_fiat_crypto.byte
1212
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --source-map $(EXTRA_ARGS) $< 2>&1 | \
13-
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME)
13+
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME) | \
14+
sh ../utils/aggregate.sh $(KIND)
1415

1516
bedrock2_fiat_crypto.byte: bedrock2_fiat_crypto.ml
1617
ocamlfind ocamlc -w -20 -g -linkpkg -package js_of_ocaml -g $< -o $@

benchmarks/benchmark-ocamlc/Makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ SHELL=/bin/bash -o pipefail
66

77
bench:
88
cp -r ../sources/ml .
9-
$(MAKE) perform COMPILER=js_of_ocaml SCRIPT=ocamlc.js
10-
$(MAKE) perform COMPILER=wasm_of_ocaml SCRIPT=ocamlc.wasm.js
9+
$(MAKE) perform COMPILER=js_of_ocaml SCRIPT=ocamlc.js KIND=js
10+
$(MAKE) perform COMPILER=wasm_of_ocaml SCRIPT=ocamlc.wasm.js KIND=wasm
1111

1212
ARGS=ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml ml/*.ml
1313

1414
perform:
1515
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --opt 2 --pretty `which ocamlc.byte` -o $(SCRIPT) 2>&1 | \
16-
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME)
16+
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) $(NAME) | \
17+
sh ../utils/aggregate.sh $(KIND)
1718
/usr/bin/time -f '{"compiler": "$(COMPILER)", "time":"%E"}' node $(SCRIPT) -c $(ARGS) 2>&1 | \
18-
sh ../utils/format_metrics.sh exec
19+
sh ../utils/format_metrics.sh exec | \
20+
sh ../utils/aggregate.sh $(KIND)
21+

benchmarks/benchmark-partial-render-table/Makefile

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ export NAME=Partial Render Table
55
SHELL=/bin/bash -o pipefail
66

77
bench:
8-
$(MAKE) perform COMPILER=Js_of_ocaml SCRIPT=main.bc.js
9-
$(MAKE) perform COMPILER=Wasm_of_ocaml SCRIPT=main.bc.wasm.js
8+
$(MAKE) perform COMPILER=js_of_ocaml SCRIPT=main.bc.js KIND=js
9+
$(MAKE) perform COMPILER=wasm_of_ocaml SCRIPT=main.bc.wasm.js KIND=wasm
1010

1111
BYTE_FILE=../../janestreet/_build/default/lib/bonsai_web_components/partial_render_table/bench/bin/main.bc-for-jsoo
1212

1313
perform:
1414
/usr/bin/time -f "%E %R" $(COMPILER) --debug times --opt 2 --pretty $(BYTE_FILE) -o out.js 2>&1 | \
1515
tee /dev/stderr | \
16-
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) "$(NAME)"
16+
ocaml -I +str str.cma ../utils/compilation_metrics.ml $(COMPILER) "$(NAME)" | \
17+
sh ../utils/aggregate.sh $(KIND)
1718
node $(SCRIPT) | \
1819
tee /dev/stderr | \
19-
ocaml -I +str str.cma summarize_results.ml $(COMPILER)
20+
ocaml -I +str str.cma summarize_results.ml $(COMPILER) | \
21+
sh ../utils/aggregate.sh $(KIND)

benchmarks/run.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ module Param = struct
3434
{ warm_up_time = 1.0
3535
; min_measures = 10
3636
; max_confidence = 0.03
37-
; max_duration = 20.
37+
; max_duration = 120.
3838
; verbose = false
3939
}
4040

41-
let fast x = { x with min_measures = 5; max_confidence = 0.15 }
41+
let fast x = { x with min_measures = 5; max_confidence = 0.15; max_duration = 20. }
4242

43-
let ffast x = { x with min_measures = 2; max_confidence = 42. }
43+
let ffast x = { x with min_measures = 2; max_confidence = 42.; max_duration = 20. }
4444

4545
let verbose x = { x with verbose = true }
4646
end

benchmarks/utils/aggregate.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
TEMP=$(mktemp)
3+
4+
tee $TEMP | \
5+
jq '.name |= "Js vs Wasm"' | \
6+
jq '.results[] |= select(.name | test("Code size") | not)' |\
7+
jq '.results[].metrics[].name |= if test("/") then .+"-'$1'" else .+"/'$1'" end'
8+
cat $TEMP
9+
rm $TEMP

0 commit comments

Comments
 (0)