Commit 9735c6c1 authored by POTTIER Francois's avatar POTTIER Francois

Extended speed.sh to also measure ocamlyacc's performance.

Currently equal to the performance of the table back-end.
parent 3a076fc5
......@@ -7,7 +7,9 @@ ifndef MENHIR
MENHIR := $(shell $(READLINK) -f ../../src/_stage1/menhir.native) \
--table
endif
OCAMLBUILD := ocamlbuild -use-ocamlfind -menhir "$(MENHIR)"
ifndef OCAMLBUILD
OCAMLBUILD := ocamlbuild -use-ocamlfind -use-menhir -menhir "$(MENHIR)"
endif
all:
$(OCAMLBUILD) gene.native
......
true: use_menhir, package(menhirLib)
true: package(menhirLib)
......@@ -7,27 +7,28 @@
%left TIMES DIV /* medium precedence */
%nonassoc UMINUS /* highest precedence */
%start <int> main
%start main
%type<int> main
%%
main:
| e = expr EOL
{ e }
| expr EOL
{ $1 }
expr:
| i = INT
{ i }
| LPAREN e = expr RPAREN
{ e }
| e1 = expr PLUS e2 = expr
{ e1 + e2 }
| e1 = expr MINUS e2 = expr
{ e1 - e2 }
| e1 = expr TIMES e2 = expr
{ e1 * e2 }
| e1 = expr DIV e2 = expr
{ e1 / e2 }
| MINUS e = expr %prec UMINUS
{ - e }
| INT
{ $1 }
| LPAREN expr RPAREN
{ $2 }
| expr PLUS expr
{ $1 + $3 }
| expr MINUS expr
{ $1 - $3 }
| expr TIMES expr
{ $1 * $3 }
| expr DIV expr
{ $1 / $3 }
| MINUS expr %prec UMINUS
{ - $2 }
......@@ -13,11 +13,26 @@ let code =
read "gene/code.time"
let table =
read "gene/table.time"
let ocamlyacc =
try
Some (read "gene/ocamlyacc.time")
with Sys_error _ ->
None
let optionally o f =
match o with Some x -> f x | None -> ()
let () =
printf "Test input generation takes %.2f seconds.\n" dry;
printf "Parsing with the code back-end takes %.2f seconds.\n" (code -. dry);
printf "Parsing with the table back-end takes %.2f seconds.\n" (table -. dry);
optionally ocamlyacc (fun ocamlyacc ->
printf "Parsing with ocamlyacc takes %.2f seconds.\n" (ocamlyacc -. dry);
);
printf "The table back-end is %.1f times slower than the code back-end.\n" ((table -. dry) /. (code -. dry));
optionally ocamlyacc (fun ocamlyacc ->
printf "ocamlyacc is %.1f times slower than the code back-end.\n" ((ocamlyacc -. dry) /. (code -. dry));
printf "ocamlyacc is %.1f times faster than the table back-end.\n" ((table -. dry) /. (ocamlyacc -. dry));
);
flush stdout
......@@ -15,6 +15,9 @@ fi
# Make sure Menhir and MenhirLib are up-to-date.
./build.sh
# Remove any stale performance measurements.
rm -f gene/*.time
# Build the parser with the code back-end.
echo "Building (code)..."
make -C $GENE MENHIR="$MENHIR" clean all >/dev/null
......@@ -48,5 +51,21 @@ if ! diff -q $GENE/code.out $GENE/table.out ; then
exit 1
fi
# Optionally, measure ocamlyacc's performance.
if true; then
# Build the parser with ocamlyacc.
echo "Building (ocamlyacc)..."
make -C $GENE OCAMLBUILD="ocamlbuild -use-ocamlfind" clean all >/dev/null
# Run the ocamlyacc parser.
echo ocamlyacc:
$TIME -f "%U" $GENE/gene.native > $GENE/ocamlyacc.out 2> $GENE/ocamlyacc.time
cat $GENE/ocamlyacc.time
fi
# Compute some statistics.
ocaml speed.ml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment