Skip to content

Commit

Permalink
Benchmarks: fix extra bc exe for size report
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Nov 17, 2022
1 parent bbc1a32 commit 7f09de4
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ benchmarks/__run
benchmarks/build
benchmarks/results
benchmarks/config
benchmarks/programs


doc-dev
_wikidoc
Expand Down
23 changes: 11 additions & 12 deletions benchmarks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,12 @@ __missingcompiletimes:

__missingsizes: __precomp
for i in $(missingsizes) ; do if [ ! -f $$i ] ; then echo 0 > $$i ; fi ; done
if [ ! -f results/sizes/ml/unison ] ; then echo 828471 > results/sizes/ml/unison ; fi
if [ ! -f results/sizes/ml/ocamlc ] ; then echo 800771 > results/sizes/ml/ocamlc ; fi
if [ ! -f results/sizes/ml/ocsigen_server ] ; then echo 0 > results/sizes/ml/ocsigen_server ; fi
if [ ! -f results/sizes/ml/js_of_ocaml ] ; then echo 171361 > results/sizes/ml/js_of_ocaml ; fi
if [ ! -f results/sizes/ml/boulderdash ] ; then echo 12920 > results/sizes/ml/boulderdash ; fi
if [ ! -f results/sizes/ml/canvas ] ; then echo 740 > results/sizes/ml/canvas ; fi
if [ ! -f results/sizes/ml/cubes ] ; then echo 3773 > results/sizes/ml/cubes ; fi
if [ ! -f results/sizes/ml/minesweeper ] ; then echo 7106 > results/sizes/ml/minesweeper ; fi
if [ ! -f results/sizes/ml/planet ] ; then echo 16488 > results/sizes/ml/planet ; fi
if [ ! -f results/sizes/ml/sudoku ] ; then echo 2837 > results/sizes/ml/sudoku ; fi
touch __missingsizes

# To generate SVG, we first need to run the benchs,
Expand All @@ -104,15 +100,11 @@ size.gpl: __run __missingsizes
-omit kb_no_exc \
-omit loop \
-append boulderdash \
-append canvas \
-append cubes \
-append minesweeper \
-append planet \
-append sudoku \
-append js_of_ocaml \
-append ocsigen_server \
-append ocamlc \
-append unison \
-max 3 -ylabel Size -script \
-svg 7 650 150 \
| perl -pe 'BEGIN{undef $$/;} s/e\nplot/e\nset key at 23.75,1.80\nplot/smg' \
Expand All @@ -136,15 +128,11 @@ size-optim.svg: __run __missingsizes
-omit kb_no_exc \
-omit loop \
-append boulderdash \
-append canvas \
-append cubes \
-append minesweeper \
-append planet \
-append sudoku \
-append js_of_ocaml \
-append ocsigen_server \
-append ocamlc \
-append unison \
-max 2.5 -svg 7 650 150 -edgecaption -ylabel Size \
> $@

Expand Down Expand Up @@ -187,3 +175,14 @@ _noperf:

clean: _noperf
rm -rf results build __precomp __run *.svg *.pdf *~ precomptmp __missingsizes __missingcompiletimes


copy-extra-bc:
mkdir -p programs
dune exec ./stripdebug.exe -- $(shell which ocamlc.byte) programs/ocamlc
dune build --profile bench_no_debug ../compiler/bin-js_of_ocaml/js_of_ocaml.bc ../examples/
cp -f ../_build/default/compiler/bin-js_of_ocaml/js_of_ocaml.bc programs/js_of_ocaml
cp -f ../_build/default/examples/boulderdash/boulderdash.bc programs/boulderdash
cp -f ../_build/default/examples/cubes/cubes.bc programs/cubes
cp -f ../_build/default/examples/minesweeper/main.bc programs/minesweeper
cp -f ../_build/default/examples/planet/planet.bc programs/planet
4 changes: 2 additions & 2 deletions benchmarks/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
(:standard -w -32-34-38-69))))

(executables
(names report run)
(libraries unix))
(names report run stripdebug)
(libraries unix compiler-libs.bytecomp))

(alias
(name default)
Expand Down
55 changes: 55 additions & 0 deletions benchmarks/stripdebug.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Gallium, INRIA Paris *)
(* *)
(* Copyright 2015 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)

(* Copy a bytecode executable, removing debugging information
and #! header from the copy.
Usage: stripdebug <source file> <dest file>
*)

open Printf
open Misc

let stripdebug infile outfile =
let ic = open_in_bin infile in
Bytesections.read_toc ic;
let toc = Bytesections.toc () in
let pos_first_section = Bytesections.pos_first_section ic in
let oc =
open_out_gen [ Open_wronly; Open_creat; Open_trunc; Open_binary ] 0o777 outfile
in
(* Skip the #! header, going straight to the first section. *)
seek_in ic pos_first_section;
(* Copy each section except DBUG *)
Bytesections.init_record oc;
List.iter
(fun (name, len) ->
if name = "DBUG"
then seek_in ic (pos_in ic + len)
else (
copy_file_chunk ic oc len;
Bytesections.record oc name))
toc;
(* Rewrite the toc and trailer *)
Bytesections.write_toc_and_trailer oc;
(* Done *)
close_in ic;
close_out oc

let _ =
if Array.length Sys.argv = 3
then stripdebug Sys.argv.(1) Sys.argv.(2)
else (
eprintf "Usage: stripdebug <source file> <destination file>\n";
exit 2)
9 changes: 8 additions & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
(env
(dev
(flags
(:standard -w +a-4-40-41-42-44-48-58-66-70))))
(:standard -w +a-4-40-41-42-44-48-58-66-70)))
(bench_no_debug
(flags
(:standard \ -g))
(ocamlc_flags
(:standard \ -g))
(link_flags
(:standard \ -g))))

(rule
(targets version.ml.in)
Expand Down

0 comments on commit 7f09de4

Please sign in to comment.