5 function echo_to_stderr
{
9 function usage_and_exit
{
10 echo_to_stderr
"Usage:"
11 echo_to_stderr
" $0 <path-to-js> <number-of-iterations>"
13 echo_to_stderr
"Run octane <number-of-iterations> times, and aggregate the results"
14 echo_to_stderr
"into one CSV file, which is written to stdout."
16 echo_to_stderr
"See the js/src/devtools/plot-octane.R script for plotting the"
17 echo_to_stderr
"results."
19 echo_to_stderr
"Complete example usage with plotting:"
21 echo_to_stderr
" \$ ./js/src/devtools/octane-csv.sh path/to/js 20 > control.csv"
23 echo_to_stderr
" Next, apply some patch you'd like to test."
25 echo_to_stderr
" \$ ./js/src/devtools/octane-csv.sh path/to/js 20 > variable.csv"
26 echo_to_stderr
" \$ ./js/src/devtools/plot-octane.R control.csv variable.csv"
28 echo_to_stderr
" Open Rplots.pdf to view the results."
32 if [[ "$#" != "2" ]]; then
36 # Get the absolute, normalized $JS path, and ensure its an executable.
39 if [[ ! -d "$JS_DIR" ]]; then
40 echo_to_stderr
"error: no such directory $JS_DIR"
46 cd "$JS_DIR" > /dev
/null
48 if [[ ! -e "$JS" ]]; then
49 echo_to_stderr
"error: '$JS' is not executable"
55 # Go to the js/src/octane directory.
57 cd $
(dirname $0)/..
/octane
> /dev
/null
59 # Run octane and transform the results into CSV.
61 # Run once as a warm up, and to grab the column headers. Then run the benchmark
62 # $ITERS times, grabbing just the data rows.
64 echo_to_stderr
"Warm up"
65 "$JS" .
/run.js |
grep -v -- "----" | cut
-f 1 -d ':' |
tr '\n' ','
69 while [[ "$ITERS" -ge "1" ]]; do
70 echo_to_stderr
"Iterations left: $ITERS"
71 "$JS" .
/run.js |
grep -v -- "----" | cut
-f 2 -d ':' |
tr '\n' ','
76 echo_to_stderr
"All done :)"