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 # Common functions for all the bench scripts
18 # Run a single command multiple time and store the execution times
19 # in the current $res file.
21 # $1: title of the command
22 # $2: long desription of the command
23 # rest: the command to execute
24 function bench_command
()
26 if [ "$dry_run" = "true" ]; then return; fi
31 if test "$verbose" = true
; then outputopts
="/dev/stdout"; else outputopts
="/dev/null"; fi
33 echo "$title" > "$timeout"
34 echo "# $desc" >> "$timeout"
35 echo "\$ $@" >> "$timeout"
37 echo "** [$title] $desc **"
40 # Execute the commands $count times
41 for i
in `seq 1 "$count"`; do
42 /usr
/bin
/time -f
"%U" -o
"$timeout" -a
"$@" > $outputopts 2>&1 || die
"$1: failed"
47 line
=`compute_stats "$timeout"`
52 # Run a simble command witout storing the execution time
53 # Used to display command on verbose and skip long executions when dry_run is given
54 # $@ command to execute
55 function run_command
()
57 if [ "$dry_run" = "true" ]; then return; fi
59 "$@" || die
"$@: failed"
62 # Check if the test should be skiped according to its name
63 # $1: name of the test
64 # $2: description of the test
65 # $NOTSKIPED: arguments
68 if test -z
"$NOTSKIPED"; then
72 if test "$NOTSKIPED" = "all"; then
74 elif echo "$1" |
egrep "$NOTSKIPED" >/dev
/null
2>&1; then
75 : # Found one to execute
79 if test -n
"$html"; then
80 echo >>"$html" "<h2>$1</h2>"