From: Josh Bleecher Snyder Date: Tue, 18 Apr 2017 13:57:43 +0000 (-0700) Subject: runtime: add a map growth benchmark X-Git-Tag: go1.9beta1~619 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2abd91e26564bd5ddd364b11e74e050a72766339;p=gostls13.git runtime: add a map growth benchmark Updates #19931 Updates #19992 Change-Id: Ib2d4e6b9b89a49caa443310d896dce8d6db06050 Reviewed-on: https://go-review.googlesource.com/40978 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/runtime/mapspeed_test.go b/src/runtime/mapspeed_test.go index ac93119d77..aec0c51f3f 100644 --- a/src/runtime/mapspeed_test.go +++ b/src/runtime/mapspeed_test.go @@ -5,6 +5,7 @@ package runtime_test import ( "fmt" + "strconv" "strings" "testing" ) @@ -308,6 +309,20 @@ func BenchmarkSmallKeyMap(b *testing.B) { } } +func BenchmarkMapPopulate(b *testing.B) { + for size := 1; size < 1000000; size *= 10 { + b.Run(strconv.Itoa(size), func(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + m := make(map[int]bool) + for j := 0; j < size; j++ { + m[j] = true + } + } + }) + } +} + type ComplexAlgKey struct { a, b, c int64 _ int