aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-03-18 18:46:04 +0000
committerMichael Knyszek <mknyszek@google.com>2020-03-23 16:55:37 +0000
commit7af6a31b48c5cb4d8cc9ca346949d1143ece76ca (patch)
tree9c86897d78e32316bf1dd1d242d64891971995c2 /src/runtime/export_test.go
parent8c30971da654a37a5f5f211e6dccf8d83e7ee463 (diff)
downloadgo-7af6a31b48c5cb4d8cc9ca346949d1143ece76ca.tar.gz
go-7af6a31b48c5cb4d8cc9ca346949d1143ece76ca.zip
runtime: add countAlloc benchmark
This change adds a small microbenchmark for (*mspan).countAlloc, which we're about to replace. Admittedly this isn't a critical piece of code, but the benchmark was useful in understanding the performance change. Change-Id: Iea93c00f571ee95534a42f2ef2ab026b382242b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/224438 Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 6a8d00c60d..67379796c7 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -975,3 +975,11 @@ func MapHashCheck(m interface{}, k interface{}) (uintptr, uintptr) {
y := typehash(kt, noescape(p), uintptr(mh.hash0))
return x, y
}
+
+func MSpanCountAlloc(bits []byte) int {
+ s := mspan{
+ nelems: uintptr(len(bits) * 8),
+ gcmarkBits: (*gcBits)(unsafe.Pointer(&bits[0])),
+ }
+ return s.countAlloc()
+}