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>
This commit is contained in:
Michael Anthony Knyszek 2020-03-18 18:46:04 +00:00 committed by Michael Knyszek
parent 8c30971da6
commit 7af6a31b48
2 changed files with 27 additions and 0 deletions

View file

@ -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()
}