Skip to content

Commit

Permalink
runtime: add a map growth benchmark
Browse files Browse the repository at this point in the history
Updates #19931
Updates #19992

Change-Id: Ib2d4e6b9b89a49caa443310d896dce8d6db06050
Reviewed-on: https://go-review.googlesource.com/40978
Run-TryBot: Josh Bleecher Snyder <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
josharian committed Apr 19, 2017
1 parent 17d497f commit 2abd91e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/runtime/mapspeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package runtime_test

import (
"fmt"
"strconv"
"strings"
"testing"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2abd91e

Please sign in to comment.