Commit 7e036521 authored by Bryan C. Mills's avatar Bryan C. Mills Committed by Bryan Mills

expvar: add benchmark for (*Map).Set with per-goroutine keys

Change-Id: I0fa68ca9812fe5e82ffb9d0b9598e95b47183eb8
Reviewed-on: https://go-review.googlesource.com/38011Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent d9fe2332
......@@ -211,6 +211,33 @@ func BenchmarkMapSet(b *testing.B) {
})
}
func BenchmarkMapSetDifferent(b *testing.B) {
procKeys := make([][]string, runtime.GOMAXPROCS(0))
for i := range procKeys {
keys := make([]string, 4)
for j := range keys {
keys[j] = fmt.Sprint(i, j)
}
procKeys[i] = keys
}
m := new(Map).Init()
v := new(Int)
b.ResetTimer()
var n int32
b.RunParallel(func(pb *testing.PB) {
i := int(atomic.AddInt32(&n, 1)-1) % len(procKeys)
keys := procKeys[i]
for pb.Next() {
for _, k := range keys {
m.Set(k, v)
}
}
})
}
func BenchmarkMapSetString(b *testing.B) {
m := new(Map).Init()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment