2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # This shell script generate gnuplot results
18 # perl function to compute min/max/avg.
19 # used by bench_command
22 # return: first min max avg label
23 function compute_stats
()
27 perl
- "$file" <<'END'
43 @lines
= sort {$a <=> $b} @lines
;
45 $max = $lines[$#lines];
47 for $i (@lines
) { $avg += $i; }
49 print
"${first} ${min} ${max} ${avg} \"${label}\"\n";
51 print
"${first} ${first} ${first} ${first} \"${label}\"\n";
56 # Create a new $res to be used in the next plot
61 function prepare_res
()
65 if test -n
"$html"; then
66 echo >>"$html" "<p>[$2] $3 <a href=\"$1\">data</a></p>"
69 if [ "$plots" = "" ]; then
70 plots
="plot '$1' using 4:2:3:xticlabels(5) ti '$2'"
72 plots
="$plots, '$1' using 4:2:3 ti '$2'"
74 if [ "$dry_run" = "true" ]; then return; fi
75 echo "# [$2] $3 ; count=$count" > "$res"
76 echo "# first min max avg title" >> "$res"
79 # Plot the last $res as an histogram
80 # $1: plot file (eg toto.gnu)
86 set style data histogram
;
87 set style histogram cluster gap
2;
88 set style histogram errorbars linewidth
1;
89 set style fill solid
0.3 border
-1;
92 set xtic nomirror rotate by
-45 scale
0 font
',8';
93 set title
"$1 ; avg. on $count-1 runs"
99 if test -n
"$html"; then
101 bn
=`basename "$1" .gnu`
102 gnuplot
-e
"set term png; set output \"$bn.png\"" "$1"
103 echo gnuplot
-e
"set term png; set output \"$bn.png\"" "$1"
105 echo >>"$html" "<img src=\"$bn.png\"/>"
107 if test -n
"$DISPLAY"; then
108 echo "# gnuplot -p $1"
113 # Create a new $res to be used in the next plot
118 function prepare_res_lines
()
122 if test -n
"$html"; then
123 echo >>"$html" "<p>[$2] $3 <a href=\"$1\">data</a></p>"
126 if [ "$plots" = "" ]; then
127 plots
="plot '$1' using 4 with lines ti '$2'"
129 plots
="$plots, '$1' using 4 with lines ti '$2'"
131 if [ "$dry_run" = "true" ]; then return; fi
132 echo "# [$2] $3 ; count=$count" > "$res"
133 echo "# first min max avg title" >> "$res"
136 # Plot the last $res as a line graph
137 # $1: plot file (eg toto.gnu)
138 function plot_lines
()
143 set xtic nomirror rotate by
-45 scale
0 font
',8';
144 set title
"$1 ; avg. on $count-1 runs"
145 set ylabel
"time (s)"
150 if test -n
"$html"; then
152 bn
=`basename "$1" .gnu`
153 gnuplot
-e
"set term png; set output \"$bn.png\"" "$1"
154 echo gnuplot
-e
"set term png; set output \"$bn.png\"" "$1"
156 echo >>"$html" "<img src=\"$bn.png\"/>"
158 if test -n
"$DISPLAY"; then
159 echo "# gnuplot -p $1"
164 ## GLOBAL VARIABLES ##
166 # The current $res (set by prepare_res, used by bench_command)
169 # The current stuff to plot (set by prepare_res, used by plot)
172 # The name of the html file if output is set to html