OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [bench/] [shootout/] [timing.sh] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
#!/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 $(gomake --no-print-directory -f ../../../src/Make.inc go-env)
9
PATH=.:$PATH
10
 
11
havegccgo=false
12
if which gccgo >/dev/null 2>&1
13
then
14
        havegccgo=true
15
fi
16
 
17
mode=run
18
case X"$1" in
19
X-test)
20
        mode=test
21
        shift
22
esac
23
 
24
gc() {
25
        $GC $1.go; $LD $1.$O
26
}
27
 
28
gc_B() {
29
        $GC -B $1.go; $LD $1.$O
30
}
31
 
32
runonly() {
33
        if [ $mode = run ]
34
        then
35
                "$@"
36
        fi
37
}
38
 
39
run() {
40
        if [ $mode = test ]
41
        then
42
                if echo $1 | grep -q '^gc '
43
                then
44
                        $1      # compile the program
45
                        program=$(echo $1 | sed 's/gc //')
46
                        shift
47
                        echo $program
48
                        $1 <fasta-1000.out > /tmp/$$
49
                        case $program in
50
                        chameneosredux)
51
                                # exact numbers may vary but non-numbers should match
52
                                grep -v '[0-9]' /tmp/$$ > /tmp/$$x
53
                                grep -v '[0-9]' chameneosredux.txt > /tmp/$$y
54
                                cmp /tmp/$$x /tmp/$$y
55
                                rm -f /tmp/$$ /tmp/$$x /tmp/$$y
56
                                ;;
57
                        *)
58
                                cmp /tmp/$$ $program.txt
59
                                rm -f /tmp/$$
60
                        esac
61
                fi
62
                return
63
        fi
64
        if ! $havegccgo && echo $1 | grep -q '^gccgo '
65
        then
66
                return
67
        fi
68
        echo -n '       '$1'    '
69
        $1
70
        shift
71
 
72
        echo $((time -p $* >/dev/null) 2>&1) | awk '{print $4 "u " $6 "s " $2 "r"}'
73
}
74
 
75
fasta() {
76
        runonly echo 'fasta -n 25000000'
77
        run 'gcc -O2 fasta.c' a.out 25000000
78
        run 'gccgo -O2 fasta.go' a.out -n 25000000      #commented out until WriteString is in bufio
79
        run 'gc fasta' $O.out -n 25000000
80
        run 'gc_B fasta' $O.out -n 25000000
81
}
82
 
83
revcomp() {
84
        runonly gcc -O2 fasta.c
85
        runonly a.out 25000000 > x
86
        runonly echo 'reverse-complement < output-of-fasta-25000000'
87
        run 'gcc -O2 reverse-complement.c' a.out < x
88
        run 'gccgo -O2 reverse-complement.go' a.out < x
89
        run 'gc reverse-complement' $O.out < x
90
        run 'gc_B reverse-complement' $O.out < x
91
        rm x
92
}
93
 
94
nbody() {
95
        runonly echo 'nbody -n 50000000'
96
        run 'gcc -O2 -lm nbody.c' a.out 50000000
97
        run 'gccgo -O2 nbody.go' a.out -n 50000000
98
        run 'gc nbody' $O.out -n 50000000
99
        run 'gc_B nbody' $O.out -n 50000000
100
}
101
 
102
binarytree() {
103
        runonly echo 'binary-tree 15 # too slow to use 20'
104
        run 'gcc -O2 binary-tree.c -lm' a.out 15
105
        run 'gccgo -O2 binary-tree.go' a.out -n 15
106
        run 'gccgo -O2 binary-tree-freelist.go' $O.out -n 15
107
        run 'gc binary-tree' $O.out -n 15
108
        run 'gc binary-tree-freelist' $O.out -n 15
109
}
110
 
111
fannkuch() {
112
        runonly echo 'fannkuch 12'
113
        run 'gcc -O2 fannkuch.c' a.out 12
114
        run 'gccgo -O2 fannkuch.go' a.out -n 12
115
        run 'gccgo -O2 fannkuch-parallel.go' a.out -n 12
116
        run 'gc fannkuch' $O.out -n 12
117
        run 'gc fannkuch-parallel' $O.out -n 12
118
        run 'gc_B fannkuch' $O.out -n 12
119
}
120
 
121
regexdna() {
122
        runonly gcc -O2 fasta.c
123
        runonly a.out 100000 > x
124
        runonly echo 'regex-dna 100000'
125
        run 'gcc -O2 regex-dna.c -lpcre' a.out <x
126
        run 'gccgo -O2 regex-dna.go' a.out <x
127
        run 'gccgo -O2 regex-dna-parallel.go' a.out <x
128
        run 'gc regex-dna' $O.out <x
129
        run 'gc regex-dna-parallel' $O.out <x
130
        run 'gc_B regex-dna' $O.out <x
131
        rm x
132
}
133
 
134
spectralnorm() {
135
        runonly echo 'spectral-norm 5500'
136
        run 'gcc -O2 spectral-norm.c -lm' a.out 5500
137
        run 'gccgo -O2 spectral-norm.go' a.out -n 5500
138
        run 'gc spectral-norm' $O.out -n 5500
139
        run 'gc_B spectral-norm' $O.out -n 5500
140
}
141
 
142
knucleotide() {
143
        runonly gcc -O2 fasta.c
144
        runonly a.out 1000000 > x  # should be using 25000000
145
        runonly echo 'k-nucleotide 1000000'
146
        run 'gcc -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include k-nucleotide.c -lglib-2.0' a.out <x
147
        run 'gccgo -O2 k-nucleotide.go' a.out <x
148
        run 'gccgo -O2 k-nucleotide-parallel.go' a.out <x
149
        run 'gc k-nucleotide' $O.out <x
150
        run 'gc k-nucleotide-parallel' $O.out <x
151
        run 'gc_B k-nucleotide' $O.out <x
152
        rm x
153
}
154
 
155
mandelbrot() {
156
        runonly echo 'mandelbrot 16000'
157
        run 'gcc -O2 mandelbrot.c' a.out 16000
158
        run 'gccgo -O2 mandelbrot.go' a.out -n 16000
159
        run 'gc mandelbrot' $O.out -n 16000
160
        run 'gc_B mandelbrot' $O.out -n 16000
161
}
162
 
163
meteor() {
164
        runonly echo 'meteor 2098'
165
        run 'gcc -O2 meteor-contest.c' a.out 2098
166
        run 'gccgo -O2 meteor-contest.go' a.out -n 2098
167
        run 'gc meteor-contest' $O.out -n 2098
168
        run 'gc_B  meteor-contest' $O.out -n 2098
169
}
170
 
171
pidigits() {
172
        runonly echo 'pidigits 10000'
173
        run 'gcc -O2 pidigits.c -lgmp' a.out 10000
174
        run 'gccgo -O2 pidigits.go' a.out -n 10000
175
        run 'gc pidigits' $O.out -n 10000
176
        run 'gc_B  pidigits' $O.out -n 10000
177
}
178
 
179
threadring() {
180
        runonly echo 'threadring 50000000'
181
        run 'gcc -O2 threadring.c -lpthread' a.out 50000000
182
        run 'gccgo -O2 threadring.go' a.out -n 50000000
183
        run 'gc threadring' $O.out -n 50000000
184
}
185
 
186
chameneos() {
187
        runonly echo 'chameneos 6000000'
188
        run 'gcc -O2 chameneosredux.c -lpthread' a.out 6000000
189
        run 'gccgo -O2 chameneosredux.go' a.out 6000000
190
        run 'gc chameneosredux' $O.out 6000000
191
}
192
 
193
case $# in
194
0)
195
        run="fasta revcomp nbody binarytree fannkuch regexdna spectralnorm knucleotide mandelbrot meteor pidigits threadring chameneos"
196
        ;;
197
*)
198
        run=$*
199
esac
200
 
201
for i in $run
202
do
203
        $i
204
        runonly echo
205
done

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.