README: document nit_env.sh
[nit.git] / benchmarks / bench_nitdoc.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_nitdoc [options]* git-ref"
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 REF="$*"
50
51 if test -z "$REF"; 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/nitdoc.nit -o ./nitdoc.orig
58 git checkout $current_branch && ../bin/nitc ../src/nitdoc.nit -o ./nitdoc.new
59
60 ## EFFECTIVE BENCHS ##
61
62 function bench_nitdoc()
63 {
64 basedir="./bench_nitdoc.out/${name}.out"
65 tests=(../tests/test_prog ../lib/standard/kernel.nit ../lib/standard)
66 mkdir -p $basedir
67
68 prepare_res $basedir/orig.dat $REF "nitdoc.orig"
69 for path in ${tests[@]}; do
70 run_gen $basedir ./nitdoc.orig $path
71 done
72
73 prepare_res $basedir/new.dat "HEAD" "nitdoc.new"
74 for path in ${tests[@]}; do
75 run_gen $basedir ./nitdoc.new $path
76 done
77
78 plot $basedir/bench_nitdoc.gnu
79 }
80
81 function run_gen()
82 {
83 basedir="$1"
84 bin="$2"
85 path="$3"
86 name=`basename $path .nit`
87 bench_command $name $path $bin $path -d $basedir/$bin.out
88 }
89
90 bench_nitdoc
91
92 if test -n "$died"; then
93 echo "Some commands failed"
94 exit 1
95 fi
96 exit 0