Commit 5b8fb084 authored by Emile Trotignon's avatar Emile Trotignon

benchmark cleanup

parent 4bb421b6
......@@ -35,6 +35,9 @@ let print m =
let code =
read "src/code.time"
let old_code =
read "src/old_code.time"
let table =
read "src/table.time"
let ocamlyacc =
......@@ -43,19 +46,24 @@ let ocamlyacc =
(* Display a comparison. *)
let () =
out " ----- Calc benchmark ----- \n" ;
out "Code back-end:\n";
print code;
out "Old code back-end:\n";
print old_code;
out "Table back-end:\n";
print table;
out "ocamlyacc:\n";
print ocamlyacc;
out "The table back-end is %.1f times slower than the code back-end.\n"
out "The table back-end is %.1f times slower than the code back-end.\n"
(table.time /. code.time);
out "ocamlyacc is %.1f times slower than the code back-end.\n"
out "ocamlyacc is %.1f times slower than the code back-end.\n"
(ocamlyacc.time /. code.time);
out "ocamlyacc is %.1f times faster than the table back-end.\n"
out "ocamlyacc is %.1f times faster than the table back-end.\n"
(table.time /. ocamlyacc.time);
out "The new code backend is %.1f times faster than the old code back-end.\n"
(old_code.time /. code.time);
out "\n";
out "The table back-end allocates %.1f times more memory \
......
......@@ -24,6 +24,10 @@ for size in 5000000 ; do
# Run the code back-end.
echo Running the code back-end...
src/code/gene.exe --size $size > src/code.out 2> src/code.time
# Run the code back-end.
echo Running the code back-end...
src/old_code/gene.exe --size $size > src/old_code.out 2> src/old_code.time
# cat src/code.time
# Run the table back-end.
......@@ -41,6 +45,16 @@ for size in 5000000 ; do
exit 1
fi
# Avoid a gross mistake.
if ! diff -q src/code.out src/old_code.out ; then
echo CAUTION: the new and old code back-ends disagree!
echo New:
cat src/code.out
echo Old:
cat src/old_code.out
exit 1
fi
# Run the ocamlyacc parser.
echo Running ocamlyacc...
src/ocamlyacc/gene.exe --size $size > src/ocamlyacc.out 2> src/ocamlyacc.time
......
......@@ -4,6 +4,7 @@
code/gene.exe
table/gene.exe
ocamlyacc/gene.exe
old_code/gene.exe
../speed.sh
../speed.ml
)
......
(copy_files# ../*.ml)
(copy_files ../parser.mly)
(menhir
(modules parser)
(flags --old-code-backend)
)
(executable
(name gene)
(libraries unix sek)
)
......@@ -58,7 +58,7 @@ let read f =
(* Printing a measurement. *)
let print m =
out "Time : %.1f seconds per billion tokens.\n"
out "Time : %.1f seconds per billion tokens.\n"
(m.time *. 1000000000.0 /. m.tokens) ;
out "Space: %.2f words per token (minor) and %.2f words per token (major).\n"
(m.minor /. m.tokens) (m.major /. m.tokens) ;
......@@ -101,7 +101,7 @@ let () =
(m.table.time /. m.code.time) ;
out "\n" ;
out
"The table back-end allocates %.1f times more memory than the new code \
"The old code back-end allocates %.1f times more memory than the new code \
back-end.\n"
(m.table.minor /. m.code.minor) ;
(m.old_code.minor /. m.code.minor) ;
flush stdout
......@@ -15,7 +15,7 @@ let seed = ref 61112962
(* [--runs] allows the desired number of runs to be set via the command line. *)
let runs = ref 10
let runs = ref 100
(* [--size] allows the size of the randomly-generated expression to be
set via the command line. *)
......
This diff is collapsed.
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