benchmark old ns/op new ns/op delta
BenchmarkAlignedLoad-160 8.67 7.42 -14.42%
BenchmarkUnalignedLoad-160 8.63 7.37 -14.60%
Change-Id: Id4609d7b4038c4d2ec332efc4fe6f1adfb61b82b
Reviewed-on: https://go-review.googlesource.com/20812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
setTraceback(level)
traceback_env = traceback_cache
}
+
+var ReadUnaligned32 = readUnaligned32
+var ReadUnaligned64 = readUnaligned64
. "runtime"
"strings"
"testing"
+ "unsafe"
)
// Smhasher is a torture test for hash functions.
t.Errorf("too many allocs %f - hash not balanced", n)
}
}
+
+var sink uint64
+
+func BenchmarkAlignedLoad(b *testing.B) {
+ var buf [16]byte
+ p := unsafe.Pointer(&buf[0])
+ var s uint64
+ for i := 0; i < b.N; i++ {
+ s += ReadUnaligned64(p)
+ }
+ sink = s
+}
+func BenchmarkUnalignedLoad(b *testing.B) {
+ var buf [16]byte
+ p := unsafe.Pointer(&buf[1])
+ var s uint64
+ for i := 0; i < b.N; i++ {
+ s += ReadUnaligned64(p)
+ }
+ sink = s
+}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build 386 amd64 amd64p32 arm64
+// +build 386 amd64 amd64p32 arm64 ppc64 ppc64le
package runtime
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build arm ppc64 ppc64le mips64 mips64le
+// +build arm mips64 mips64le
package runtime