README: document nit_env.sh
[nit.git] / benchmarks / bench_nitunit.sh
1 #!/bin/bash
2 # This file is part of NIT ( http://www.nitlanguage.org ).
3 #
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
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15
16 # Bench nitdoc perfs.
17
18 source ./bench_common.sh
19 source ./bench_plot.sh
20
21 ## CONFIGURATION OPTIONS ##
22
23 # Default number of times a command must be run with bench_command
24 # Can be overrided with 'the option -n'
25 count=3
26
27 ## HANDLE OPTIONS ##
28
29 function usage()
30 {
31 echo "bench_nitunit [options]*"
32 echo " -v: verbose mode"
33 echo " -n count: number of execution for each bar (default: $count)"
34 echo " --dry: Do not run the commands, just reuse the data and generate the graph"
35 echo " -h: this help"
36 }
37
38 stop=false
39 while [ "$stop" = false ]; do
40 case "$1" in
41 -v) verbose=true; shift;;
42 -h) usage; exit;;
43 -n) count="$2"; shift; shift;;
44 --dry) dry_run=true; shift;;
45 *) stop=true
46 esac
47 done
48
49 NOTSKIPED="$*"
50
51 if test -z "$NOTSKIPED"; then
52 usage
53 fi
54
55 ## COMPILE ENGINES
56 current_branch=`git rev-parse --abbrev-ref HEAD`
57 git checkout origin/master && ../bin/nitc ../src/nitunit.nit -o ./nitunit.orig
58 git checkout $current_branch && ../bin/nitc ../src/nitunit.nit -o ./nitunit.new
59
60 ## EFFECTIVE BENCHS ##
61
62 function bench_nitunit()
63 {
64 basedir="./bench_nitunit.out/${name}.out"
65 tests=(../lib/standard/kernel.nit ../lib/standard/string.nit ../lib/standard/collection)
66 mkdir -p $basedir
67
68 prepare_res $basedir/orig.dat "origin/master" "nitunit.orig"
69 for path in ${tests[@]}; do
70 run_gen ./nitunit.orig $path
71 done
72
73 prepare_res $basedir/new.dat "HEAD" "nitunit.new"
74 for path in ${tests[@]}; do
75 run_gen ./nitunit.new $path
76 done
77
78 plot $basedir/bench_nitunit.gnu
79 }
80
81 function run_gen()
82 {
83 bin="$1"
84 path="$2"
85 name=`basename $path .nit`
86 bench_command $name $path $bin $path
87 }
88
89 bench_nitunit
90
91 if test -n "$died"; then
92 echo "Some commands failed"
93 exit 1
94 fi
95 exit 0