aboutsummaryrefslogtreecommitdiffstats
path: root/prog/mutation_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-02-09 12:02:37 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-02-09 14:09:19 +0200
commiteb99c7d3da996d1a1dabd18aea6781262648dadb (patch)
tree085dc11b39771626c09e06fbd52f52fdfdfaff3f /prog/mutation_test.go
parent4f453297df90dffc5b5b76efcea073604b32ed02 (diff)
prog: remove use of unsafe
Unsafe is, well, unsafe. Plus it fails under the new checkptr mode in go1.14. Remove use of unsafe. No statistically significant change in performance: name old time/op new time/op delta StoreLoadInt-8 21.2ns ± 5% 21.6ns ± 9% ~ (p=0.136 n=20+20)
Diffstat (limited to 'prog/mutation_test.go')
-rw-r--r--prog/mutation_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 76812df2a..89fe5473a 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -494,3 +494,21 @@ func buildTestContext(test [2]string, target *Target) (rs rand.Source, ct *Choic
rs = rand.NewSource(0)
return
}
+
+func BenchmarkStoreLoadInt(b *testing.B) {
+ // To get unaligned data on heap (compiler manages to align it on stack).
+ data := make([]byte, 9)
+ sink = data
+ data = sink.([]byte)[1:]
+ for i := 0; i < b.N; i++ {
+ for size := 1; size <= 8; size *= 2 {
+ storeInt(data, uint64(i), size)
+ v := loadInt(data, size)
+ if uint8(v) != uint8(i) {
+ panic("bad")
+ }
+ }
+ }
+}
+
+var sink interface{}