Debian Codegraph @

shootout/timing.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 # Copyright 2009 The Go Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
5
6 set -e
7
8 eval $(goscip-shell system . . go. tool dist env)
9 GC="go tool compile"
10 LD="go tool link"
11
12 gccm=""
13 case "$O" in
14 8)
15 gccm=-m32;;
16 6)
17 gccm=-m64;;
18 esac
19
20 EXE="out"
21 havepcre=true
22 haveglib=true
23 havegmp=true
24 case "$(unamescip-shell system . . uname.)" in
25 *MINGW* | *WIN32* | *CYGWIN*)
26 havepcre=false
27 haveglib=false
28 havegmp=false
29 if whichscip-shell system . . which. pkg-config >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
30 if pkg-config --cflags libpcre >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
31 then
32 echoscip-shell system . . echo. "havepcre"
33 havepcre=true
34 fi
35 if pkg-config --cflags glib-2.0 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
36 then
37 haveglib=true
38 fi
39 if pkg-config --cflags gmp >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
40 then
41 havegmp=true
42 fi
43 fi
44 EXE=exe;;
45 esac
46
47 PATH=.:$PATH
48
49 havegccgo=false
50 if whichscip-shell system . . which. gccgo >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
51 then
52 havegccgo=true
53 fi
54
55 mode=run
56 case X"$1" in
57 X-test)
58 mode=test
59 shift
60 esac
61
62 gcscip-shell shell shell-project 0.0.0 gc().() {
63 $GC $1.go; $LD -o a.$EXE $1.o
64 }
65
66 gc_Bscip-shell shell shell-project 0.0.0 gc_B().() {
67 $GC -B $1.go; $LD -o a.$EXE $1.o
68 }
69
70 runonlyscip-shell shell shell-project 0.0.0 runonly().() {
71 if [scip-shell system . . `[`. $mode = run ]
72 then
73 "$@"
74 fi
75 }
76
77 runscip-shell shell shell-project 0.0.0 run().() {
78 if [scip-shell system . . `[`. $mode = test ]
79 then
80 if echoscip-shell system . . echo. $1 | grepscip-shell system . . grep. -q '^gc '
81 then
82 $1 # compile the program
83 program=$(echoscip-shell system . . echo. $1 | sedscip-shell system . . sed. 's/gc //')
84 shift
85 echoscip-shell system . . echo. $program
86 $1 <fasta-1000.txt > /tmp/$$
87 case $program in
88 chameneosredux)
89 # exact numbers may vary but non-numbers should match
90 grepscip-shell system . . grep. -v '[0-9]' /tmp/$$ > /tmp/$$x
91 grepscip-shell system . . grep. -v '[0-9]' chameneosredux.txt > /tmp/$$y
92 cmpscip-shell system . . cmp. /tmp/$$x /tmp/$$y
93 rmscip-shell system . . rm. -f /tmp/$$ /tmp/$$x /tmp/$$y
94 ;;
95 *)
96 cmpscip-shell system . . cmp. /tmp/$$ $program.txt
97 rmscip-shell system . . rm. -f /tmp/$$
98 esac
99 fi
100 return
101 fi
102 if ! $havegccgo && echoscip-shell system . . echo. $1 | grepscip-shell system . . grep. -q '^gccgo '
103 then
104 return
105 fi
106 echoscip-shell system . . echo. -n ' '$1' '
107 $1
108 shift
109
110 echoscip-shell system . . echo. $((time -p $* >/dev/null) 2>&1) | awkscip-shell system . . awk. '{print $4 "u " $6 "s " $2 "r"}'
111 }
112
113 fastascip-shell shell shell-project 0.0.0 fasta().() {
114 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'fasta -n 25000000'
115 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 fasta.c" a.$EXE 25000000
116 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 fasta.go' a.$EXE -n 25000000 #commented out until WriteString is in bufio
117 runscip-shell shell shell-project 0.0.0 run(). 'gc fasta' a.$EXE -n 25000000
118 runscip-shell shell shell-project 0.0.0 run(). 'gc_B fasta' a.$EXE -n 25000000
119 }
120
121 revcompscip-shell shell shell-project 0.0.0 revcomp().() {
122 runonlyscip-shell shell shell-project 0.0.0 runonly(). gcc -O2 fasta.c
123 runonlyscip-shell shell shell-project 0.0.0 runonly(). a.$EXE 25000000 > x
124 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'reverse-complement < output-of-fasta-25000000'
125 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 reverse-complement.c" a.$EXE < x
126 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 reverse-complement.go' a.$EXE < x
127 runscip-shell shell shell-project 0.0.0 run(). 'gc reverse-complement' a.$EXE < x
128 runscip-shell shell shell-project 0.0.0 run(). 'gc_B reverse-complement' a.$EXE < x
129 rmscip-shell system . . rm. x
130 }
131
132 nbodyscip-shell shell shell-project 0.0.0 nbody().() {
133 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'nbody -n 50000000'
134 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 nbody.c -lm" a.$EXE 50000000
135 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 nbody.go' a.$EXE -n 50000000
136 runscip-shell shell shell-project 0.0.0 run(). 'gc nbody' a.$EXE -n 50000000
137 runscip-shell shell shell-project 0.0.0 run(). 'gc_B nbody' a.$EXE -n 50000000
138 }
139
140 binarytreescip-shell shell shell-project 0.0.0 binarytree().() {
141 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'binary-tree 15 # too slow to use 20'
142 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 binary-tree.c -lm" a.$EXE 15
143 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 binary-tree.go' a.$EXE -n 15
144 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 binary-tree-freelist.go' a.$EXE -n 15
145 runscip-shell shell shell-project 0.0.0 run(). 'gc binary-tree' a.$EXE -n 15
146 runscip-shell shell shell-project 0.0.0 run(). 'gc binary-tree-freelist' a.$EXE -n 15
147 }
148
149 fannkuchscip-shell shell shell-project 0.0.0 fannkuch().() {
150 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'fannkuch 12'
151 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 fannkuch.c" a.$EXE 12
152 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 fannkuch.go' a.$EXE -n 12
153 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 fannkuch-parallel.go' a.$EXE -n 12
154 runscip-shell shell shell-project 0.0.0 run(). 'gc fannkuch' a.$EXE -n 12
155 runscip-shell shell shell-project 0.0.0 run(). 'gc fannkuch-parallel' a.$EXE -n 12
156 runscip-shell shell shell-project 0.0.0 run(). 'gc_B fannkuch' a.$EXE -n 12
157 }
158
159 regexdnascip-shell shell shell-project 0.0.0 regexdna().() {
160 runonlyscip-shell shell shell-project 0.0.0 runonly(). gcc -O2 fasta.c
161 runonlyscip-shell shell shell-project 0.0.0 runonly(). a.$EXE 100000 > x
162 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'regex-dna 100000'
163 if $havepcre; then
164 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 regex-dna.c $(pkg-config libpcre --cflags --libs)" a.$EXE <x
165 fi
166 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 regex-dna.go' a.$EXE <x
167 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 regex-dna-parallel.go' a.$EXE <x
168 runscip-shell shell shell-project 0.0.0 run(). 'gc regex-dna' a.$EXE <x
169 runscip-shell shell shell-project 0.0.0 run(). 'gc regex-dna-parallel' a.$EXE <x
170 runscip-shell shell shell-project 0.0.0 run(). 'gc_B regex-dna' a.$EXE <x
171 rmscip-shell system . . rm. x
172 }
173
174 spectralnormscip-shell shell shell-project 0.0.0 spectralnorm().() {
175 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'spectral-norm 5500'
176 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 spectral-norm.c -lm" a.$EXE 5500
177 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 spectral-norm.go' a.$EXE -n 5500
178 runscip-shell shell shell-project 0.0.0 run(). 'gc spectral-norm' a.$EXE -n 5500
179 runscip-shell shell shell-project 0.0.0 run(). 'gc_B spectral-norm' a.$EXE -n 5500
180 }
181
182 knucleotidescip-shell shell shell-project 0.0.0 knucleotide().() {
183 runonlyscip-shell shell shell-project 0.0.0 runonly(). gcc -O2 fasta.c
184 runonlyscip-shell shell shell-project 0.0.0 runonly(). a.$EXE 1000000 > x # should be using 25000000
185 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'k-nucleotide 1000000'
186 if [scip-shell system . . `[`. $mode = run ] && $haveglib; then
187 runscip-shell shell shell-project 0.0.0 run(). "gcc -O2 k-nucleotide.c $(pkg-config glib-2.0 --cflags --libs)" a.$EXE <x
188 fi
189 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 k-nucleotide.go' a.$EXE <x
190 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 k-nucleotide-parallel.go' a.$EXE <x
191 runscip-shell shell shell-project 0.0.0 run(). 'gc k-nucleotide' a.$EXE <x
192 runscip-shell shell shell-project 0.0.0 run(). 'gc k-nucleotide-parallel' a.$EXE <x
193 runscip-shell shell shell-project 0.0.0 run(). 'gc_B k-nucleotide' a.$EXE <x
194 rmscip-shell system . . rm. x
195 }
196
197 mandelbrotscip-shell shell shell-project 0.0.0 mandelbrot().() {
198 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'mandelbrot 16000'
199 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 mandelbrot.c" a.$EXE 16000
200 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 mandelbrot.go' a.$EXE -n 16000
201 runscip-shell shell shell-project 0.0.0 run(). 'gc mandelbrot' a.$EXE -n 16000
202 runscip-shell shell shell-project 0.0.0 run(). 'gc_B mandelbrot' a.$EXE -n 16000
203 }
204
205 meteorscip-shell shell shell-project 0.0.0 meteor().() {
206 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'meteor 2098'
207 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 meteor-contest.c" a.$EXE 2098
208 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 meteor-contest.go' a.$EXE -n 2098
209 runscip-shell shell shell-project 0.0.0 run(). 'gc meteor-contest' a.$EXE -n 2098
210 runscip-shell shell shell-project 0.0.0 run(). 'gc_B meteor-contest' a.$EXE -n 2098
211 }
212
213 pidigitsscip-shell shell shell-project 0.0.0 pidigits().() {
214 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'pidigits 10000'
215 if $havegmp; then
216 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 pidigits.c -lgmp" a.$EXE 10000
217 fi
218 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 pidigits.go' a.$EXE -n 10000
219 runscip-shell shell shell-project 0.0.0 run(). 'gc pidigits' a.$EXE -n 10000
220 runscip-shell shell shell-project 0.0.0 run(). 'gc_B pidigits' a.$EXE -n 10000
221 }
222
223 threadringscip-shell shell shell-project 0.0.0 threadring().() {
224 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'threadring 50000000'
225 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 threadring.c -lpthread" a.$EXE 50000000
226 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 threadring.go' a.$EXE -n 50000000
227 runscip-shell shell shell-project 0.0.0 run(). 'gc threadring' a.$EXE -n 50000000
228 }
229
230 chameneosscip-shell shell shell-project 0.0.0 chameneos().() {
231 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo 'chameneos 6000000'
232 runscip-shell shell shell-project 0.0.0 run(). "gcc $gccm -O2 chameneosredux.c -lpthread" a.$EXE 6000000
233 runscip-shell shell shell-project 0.0.0 run(). 'gccgo -O2 chameneosredux.go' a.$EXE 6000000
234 runscip-shell shell shell-project 0.0.0 run(). 'gc chameneosredux' a.$EXE 6000000
235 }
236
237 case $# in
238 0)
239 run="fasta revcomp nbody binarytree fannkuch regexdna spectralnorm knucleotide mandelbrot meteor pidigits threadring chameneos"
240 ;;
241 *)
242 run=$*
243 esac
244
245 for i in $run
246 do
247 $i
248 runonlyscip-shell shell shell-project 0.0.0 runonly(). echo
249 done
250
251 rmscip-shell system . . rm. *.o *.$EXE # Clean up
252