diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2017-04-18 06:57:43 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-04-19 13:47:21 +0000 |
| commit | 2abd91e26564bd5ddd364b11e74e050a72766339 (patch) | |
| tree | 69fe60a6e1afbdf0ab875996ac0f69924a9c9ee1 /src/runtime | |
| parent | 17d497feaabfee336e9eaec91803a5e9aff77bdb (diff) | |
| download | go-2abd91e26564bd5ddd364b11e74e050a72766339.tar.xz | |
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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/mapspeed_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
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 |
