Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bench: Add double translation to benchmarks #1855

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions benchmarks/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ module Spec : sig

val js_of_ocaml_call : t

val js_of_ocaml_effects : t
val js_of_ocaml_effects_cps : t

val js_of_ocaml_effects_double_translation : t
end = struct
type t =
{ dir : string
Expand Down Expand Up @@ -226,7 +228,9 @@ end = struct

let js_of_ocaml_call = create "nooptcall" ".js"

let js_of_ocaml_effects = create "effects" ".js"
let js_of_ocaml_effects_cps = create "effects-cps" ".js"

let js_of_ocaml_effects_double_translation = create "effects-double-translation" ".js"
end

let rec mkdir d =
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/report-size-bzip2-effects.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
histogramref sizes "" js_of_ocaml/bzip2 #fbaf4f direct (bzip2)
histogram sizes "" effects/bzip2 #fb4f4f effects (bzip2)
histogram sizes "" effects-cps/bzip2 #fb4f4f cps (bzip2)
histogram sizes "" effects-double-translation/bzip2 #833d3d double-translation (bzip2)
3 changes: 2 additions & 1 deletion benchmarks/report-size-effects.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
histogramref sizes "" js_of_ocaml/generated #fbaf4f direct
histogram sizes "" effects #fb4f4f effects
histogram sizes "" effects-cps #fb4f4f cps
histogram sizes "" effects-double-translation #833d3d double-translation
3 changes: 2 additions & 1 deletion benchmarks/report-size-gzipped-effects.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
histogramref sizes "" js_of_ocaml/gzipped #fbaf4f direct (gzip)
histogram sizes "" effects/gzipped #fb4f4f effects (gzip)
histogram sizes "" effects-cps/gzipped #fb4f4f cps (gzip)
histogram sizes "" effects-double-translation/gzipped #833d3d double-translation (gzip)
3 changes: 2 additions & 1 deletion benchmarks/report-time-effects.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
histogramref times node js_of_ocaml #fbaf4f default
histogram times node effects #fb4f4f --enable=effects
histogram times node effects-cps #fb4f4f --effects=cps
histogram times node effects-double-translation #833d3d --effects=double-translation
52 changes: 42 additions & 10 deletions benchmarks/run.ml
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,15 @@ let _ =
let param = !param in
let interpreters = read_config conf_file in
let compile = compile param ~comptime:true in
let compile_jsoo ?(effects = false) opts =
let compile_jsoo ?(effects = `None) opts =
compile
(Format.sprintf
"js_of_ocaml -q --target-env browser --debug mark-runtime-gen %s %s"
opts
(if effects then "--enable=effects" else "--disable=effects"))
(match effects with
| `None -> ""
| `Cps -> "--effects=cps"
| `Double_translation -> "--effects=double-translation"))
in
Format.eprintf "Compile@.";
compile "ocamlc" src Spec.ml code Spec.byte;
Expand All @@ -260,7 +263,14 @@ let _ =
compile_jsoo "--disable deadcode" code Spec.byte code Spec.js_of_ocaml_deadcode;
compile_jsoo "--disable compact" code Spec.byte code Spec.js_of_ocaml_compact;
compile_jsoo "--disable optcall" code Spec.byte code Spec.js_of_ocaml_call;
compile_jsoo ~effects:true "" code Spec.byte code Spec.js_of_ocaml_effects;
compile_jsoo ~effects:`Cps "" code Spec.byte code Spec.js_of_ocaml_effects_cps;
compile_jsoo
~effects:`Double_translation
""
code
Spec.byte
code
Spec.js_of_ocaml_effects_double_translation;
compile "ocamlc -unsafe" src Spec.ml code Spec.byte_unsafe;
compile "ocamlopt" src Spec.ml code Spec.opt_unsafe;
compile_jsoo "" code Spec.byte_unsafe code Spec.js_of_ocaml_unsafe;
Expand All @@ -277,15 +287,27 @@ let _ =
compr_file_size
param
code
Spec.js_of_ocaml_effects
Spec.js_of_ocaml_effects_cps
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects_cps "gzipped");
compr_file_size
param
code
Spec.js_of_ocaml_effects_double_translation
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects "gzipped");
(Spec.sub_spec Spec.js_of_ocaml_effects_double_translation "gzipped");
bzip2_file_size
param
code
Spec.js_of_ocaml_effects
Spec.js_of_ocaml_effects_cps
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects "bzip2");
(Spec.sub_spec Spec.js_of_ocaml_effects_cps "bzip2");
bzip2_file_size
param
code
Spec.js_of_ocaml_effects_double_translation
sizes
(Spec.sub_spec Spec.js_of_ocaml_effects_double_translation "bzip2");
bzip2_file_size
param
code
Expand All @@ -305,7 +327,13 @@ let _ =
gen_size param code Spec.js_of_ocaml_deadcode sizes Spec.js_of_ocaml_deadcode;
gen_size param code Spec.js_of_ocaml_compact sizes Spec.js_of_ocaml_compact;
gen_size param code Spec.js_of_ocaml_call sizes Spec.js_of_ocaml_call;
gen_size param code Spec.js_of_ocaml_effects sizes Spec.js_of_ocaml_effects;
gen_size param code Spec.js_of_ocaml_effects_cps sizes Spec.js_of_ocaml_effects_cps;
gen_size
param
code
Spec.js_of_ocaml_effects_double_translation
sizes
Spec.js_of_ocaml_effects_double_translation;
if compile_only then exit 0;
Format.eprintf "Measure@.";
if not nobyteopt
Expand All @@ -324,14 +352,18 @@ let _ =
; Some Spec.js_of_ocaml_deadcode
; Some Spec.js_of_ocaml_compact
; Some Spec.js_of_ocaml_call
; Some Spec.js_of_ocaml_effects
; Some Spec.js_of_ocaml_effects_cps
; Some Spec.js_of_ocaml_effects_double_translation
] )
else if effects
then
( (match interpreters with
| i :: _ -> [ i ]
| [] -> [])
, [ Some Spec.js_of_ocaml; Some Spec.js_of_ocaml_effects ] )
, [ Some Spec.js_of_ocaml
; Some Spec.js_of_ocaml_effects_cps
; Some Spec.js_of_ocaml_effects_double_translation
] )
else
( (match interpreters with
| i :: _ -> [ i ]
Expand Down
Loading