Commit 35135c20 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Modify the speed test in speed.sh to NOT link MenhirLib when using the

code back-end. This should avoid some strange effects due to changes in
code size.
parent dd62940d
...@@ -4,11 +4,10 @@ ...@@ -4,11 +4,10 @@
# This is useful because ocamlbuild descends into _build. # This is useful because ocamlbuild descends into _build.
ifndef MENHIR ifndef MENHIR
READLINK := $(shell if which greadlink >/dev/null ; then echo greadlink ; else echo readlink ; fi) READLINK := $(shell if which greadlink >/dev/null ; then echo greadlink ; else echo readlink ; fi)
MENHIR := $(shell $(READLINK) -f ../../src/_stage1/menhir.native) \ MENHIR := $(shell $(READLINK) -f ../../src/_stage1/menhir.native)
--table
endif endif
ifndef OCAMLBUILD ifndef OCAMLBUILD
OCAMLBUILD := ocamlbuild -use-ocamlfind -use-menhir -menhir "$(MENHIR)" OCAMLBUILD := ocamlbuild -use-ocamlfind -use-menhir -menhir "$(MENHIR)" $(TAGS)
endif endif
all: all:
......
true: package(menhirLib)
...@@ -71,6 +71,20 @@ let wrap token = ...@@ -71,6 +71,20 @@ let wrap token =
let () = let () =
Random.init !seed Random.init !seed
(* Copied from MenhirLib in order to avoid a dependency on it. *)
let traditional2revised parser =
fun (lexer : unit -> 'token) ->
let lexbuf : Lexing.lexbuf =
Lexing.from_string ""
in
let lexer (lexbuf : Lexing.lexbuf) : 'raw_token =
let (token, startp, endp) = lexer() in
lexbuf.Lexing.lex_start_p <- startp;
lexbuf.Lexing.lex_curr_p <- endp;
token
in
parser lexer lexbuf
let () = let () =
let tks : token stream = produce !size in let tks : token stream = produce !size in
let tks = fresh (map wrap tks) in let tks = fresh (map wrap tks) in
...@@ -79,7 +93,7 @@ let () = ...@@ -79,7 +93,7 @@ let () =
printf "Done.\n" printf "Done.\n"
end end
else begin else begin
let i : int = MenhirLib.Convert.Simplified.traditional2revised Parser.main tks in let i : int = traditional2revised Parser.main tks in
printf "%d\n%!" i printf "%d\n%!" i
end end
...@@ -22,13 +22,15 @@ test_ocamlyacc=false ...@@ -22,13 +22,15 @@ test_ocamlyacc=false
rm -f gene/*.time rm -f gene/*.time
# Build the parser with the code back-end. # Build the parser with the code back-end.
# Do not link MenhirLib.
echo "Building (code)..." echo "Building (code)..."
make -C $GENE MENHIR="$MENHIR" clean all >/dev/null make -C $GENE MENHIR="$MENHIR" clean all >/dev/null
cp -RH $GENE/gene.native $GENE/gene.code cp -RH $GENE/gene.native $GENE/gene.code
# Build the parser with the table back-end. # Build the parser with the table back-end.
# Do link MenhirLib.
echo "Building (table)..." echo "Building (table)..."
make -C $GENE MENHIR="$MENHIR --table" clean all >/dev/null make -C $GENE MENHIR="$MENHIR --table" TAGS="-tags 'package(menhirLib)'" clean all >/dev/null
cp -RH $GENE/gene.native $GENE/gene.table cp -RH $GENE/gene.native $GENE/gene.table
# (Optionally) Build the parser with ocamlyacc. # (Optionally) Build the parser with ocamlyacc.
......
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