1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
17 var buf = make([]byte, 1048576)
19 func BenchmarkFastNonASCII(b *testing.B) {
20 for i := 0; i < b.N; i++ {
25 func BenchmarkSlowNonASCII(b *testing.B) {
26 for i := 0; i < b.N; i++ {
32 os.Args = []string{os.Args[0], "-test.benchtime=100ms"}
35 rslow := testing.Benchmark(BenchmarkSlowNonASCII)
36 rfast := testing.Benchmark(BenchmarkFastNonASCII)
37 tslow := rslow.NsPerOp()
38 tfast := rfast.NsPerOp()
40 // Optimization should be good for at least 2x, but be forgiving.
41 // On the ARM simulator we see closer to 1.5x.
42 speedup := float64(tslow) / float64(tfast)
44 if runtime.GOARCH == "arm" {
48 // TODO(rsc): doesn't work on linux-amd64 or darwin-amd64 builders, nor on
49 // a Lenovo x200 (linux-amd64) laptop.
50 // println("fast:", tfast, "slow:", tslow, "speedup:", speedup, "want:", want)
51 // println("not fast enough")