Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
9735c6c1
Commit
9735c6c1
authored
Dec 13, 2014
by
POTTIER Francois
Browse files
Extended speed.sh to also measure ocamlyacc's performance.
Currently equal to the performance of the table back-end.
parent
3a076fc5
Changes
5
Hide whitespace changes
Inline
Side-by-side
quicktest/gene/Makefile
View file @
9735c6c1
...
...
@@ -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
...
...
quicktest/gene/_tags
View file @
9735c6c1
true:
use_menhir,
package(menhirLib)
true: package(menhirLib)
quicktest/gene/parser.mly
View file @
9735c6c1
...
...
@@ -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
{
e
1
+
e2
}
|
e1
=
expr
MINUS
e2
=
expr
{
e
1
-
e2
}
|
e1
=
expr
TIMES
e2
=
expr
{
e
1
*
e2
}
|
e1
=
expr
DIV
e2
=
expr
{
e
1
/
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
}
quicktest/speed.ml
View file @
9735c6c1
...
...
@@ -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
quicktest/speed.sh
View file @
9735c6c1
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment