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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [fixedbugs/] [bug369.go] - Blame information for rev 858

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G -N -o slow.$A $D/bug369.dir/pkg.go &&
2
// $G -o fast.$A $D/bug369.dir/pkg.go &&
3
// $G $D/$F.go && $L $F.$A && ./$A.out
4
 
5
// Copyright 2011 The Go Authors.  All rights reserved.
6
// Use of this source code is governed by a BSD-style
7
// license that can be found in the LICENSE file.
8
 
9
// Test that compiling with optimization turned on produces faster code.
10
 
11
package main
12
 
13
import (
14
        "flag"
15
        "os"
16
        "runtime"
17
        "testing"
18
 
19
        fast "./fast"
20
        slow "./slow"
21
)
22
 
23
var buf = make([]byte, 1048576)
24
 
25
func BenchmarkFastNonASCII(b *testing.B) {
26
        for i := 0; i < b.N; i++ {
27
                fast.NonASCII(buf, 0)
28
        }
29
}
30
 
31
func BenchmarkSlowNonASCII(b *testing.B) {
32
        for i := 0; i < b.N; i++ {
33
                slow.NonASCII(buf, 0)
34
        }
35
}
36
 
37
func main() {
38
        os.Args = []string{os.Args[0], "-test.benchtime=0.1"}
39
        flag.Parse()
40
 
41
        rslow := testing.Benchmark(BenchmarkSlowNonASCII)
42
        rfast := testing.Benchmark(BenchmarkFastNonASCII)
43
        tslow := rslow.NsPerOp()
44
        tfast := rfast.NsPerOp()
45
 
46
        // Optimization should be good for at least 2x, but be forgiving.
47
        // On the ARM simulator we see closer to 1.5x.
48
        speedup := float64(tslow)/float64(tfast)
49
        want := 1.8
50
        if runtime.GOARCH == "arm" {
51
                want = 1.3
52
        }
53
        if speedup < want {
54
                // TODO(rsc): doesn't work on linux-amd64 or darwin-amd64 builders, nor on
55
                // a Lenovo x200 (linux-amd64) laptop.
56
                //println("fast:", tfast, "slow:", tslow, "speedup:", speedup, "want:", want)
57
                //println("not fast enough")
58
        }
59
}

powered by: WebSVN 2.1.0

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