]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add Benchmark[Clear|Copy]Fat[16|24]
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 18 Jul 2014 19:18:36 +0000 (12:18 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 18 Jul 2014 19:18:36 +0000 (12:18 -0700)
These benchmarks are important for performance. When compiling the stdlib:

* 77.1% of the calls to sgen (copyfat) are for 16 bytes; another 8.7% are for 24 bytes. (The next most common is 32 bytes, at 5.7%.)
* Over half the calls to clearfat are for 16 or 24 bytes.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews
https://golang.org/cl/111350043

src/pkg/runtime/memmove_test.go

index 540f0feb5495cf0266cbb7824fe3a6c0f326c5fa..09f5dbdac50a7b39232874bdbd6a8ce01d842a00 100644 (file)
@@ -162,6 +162,18 @@ func BenchmarkMemclr256(b *testing.B)   { bmMemclr(b, 256) }
 func BenchmarkMemclr4096(b *testing.B)  { bmMemclr(b, 4096) }
 func BenchmarkMemclr65536(b *testing.B) { bmMemclr(b, 65536) }
 
+func BenchmarkClearFat16(b *testing.B) {
+       for i := 0; i < b.N; i++ {
+               var x [16]byte
+               _ = x
+       }
+}
+func BenchmarkClearFat24(b *testing.B) {
+       for i := 0; i < b.N; i++ {
+               var x [24]byte
+               _ = x
+       }
+}
 func BenchmarkClearFat32(b *testing.B) {
        for i := 0; i < b.N; i++ {
                var x [32]byte
@@ -199,6 +211,20 @@ func BenchmarkClearFat1024(b *testing.B) {
        }
 }
 
+func BenchmarkCopyFat16(b *testing.B) {
+       var x [16 / 4]uint32
+       for i := 0; i < b.N; i++ {
+               y := x
+               _ = y
+       }
+}
+func BenchmarkCopyFat24(b *testing.B) {
+       var x [24 / 4]uint32
+       for i := 0; i < b.N; i++ {
+               y := x
+               _ = y
+       }
+}
 func BenchmarkCopyFat32(b *testing.B) {
        var x [32 / 4]uint32
        for i := 0; i < b.N; i++ {