Bug 1874684 - Part 29: Update spec fixme notes. r=mgaudet
[gecko.git] / js / src / devtools / octane-csv.sh
blob1049a2b47eae145564b5aa89841eb596e8914066
1 #!/usr/bin/env bash
3 set -e -o pipefail
5 function echo_to_stderr {
6 echo "$1" 1>&2
9 function usage_and_exit {
10 echo_to_stderr "Usage:"
11 echo_to_stderr " $0 <path-to-js> <number-of-iterations>"
12 echo_to_stderr
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."
15 echo_to_stderr
16 echo_to_stderr "See the js/src/devtools/plot-octane.R script for plotting the"
17 echo_to_stderr "results."
18 echo_to_stderr
19 echo_to_stderr "Complete example usage with plotting:"
20 echo_to_stderr
21 echo_to_stderr " \$ ./js/src/devtools/octane-csv.sh path/to/js 20 > control.csv"
22 echo_to_stderr
23 echo_to_stderr " Next, apply some patch you'd like to test."
24 echo_to_stderr
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"
27 echo_to_stderr
28 echo_to_stderr " Open Rplots.pdf to view the results."
29 exit 1
32 if [[ "$#" != "2" ]]; then
33 usage_and_exit
36 # Get the absolute, normalized $JS path, and ensure its an executable.
38 JS_DIR=$(dirname $1)
39 if [[ ! -d "$JS_DIR" ]]; then
40 echo_to_stderr "error: no such directory $JS_DIR"
41 echo_to_stderr
42 usage_and_exit
45 JS=$(basename $1)
46 cd "$JS_DIR" > /dev/null
47 JS="$(pwd)/$JS"
48 if [[ ! -e "$JS" ]]; then
49 echo_to_stderr "error: '$JS' is not executable"
50 echo_to_stderr
51 usage_and_exit
53 cd - > /dev/null
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' ','
66 echo
68 ITERS=$2
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' ','
72 echo
73 ITERS=$((ITERS - 1))
74 done
76 echo_to_stderr "All done :)"