1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 func mapTypes() []MapType {
14 // TODO(bradfitz): bunch more map types of all different key and value types.
15 // Use reflect.MapOf and a program to generate lots of types & struct types.
17 return []MapType{intMapType{}}
20 type MapType interface {
32 func stressMapType(mt MapType, done func()) {
36 Println("map at ", m.Len())
46 for i := 0; i < numGets; i++ {
63 type intMapType struct{}
65 func (intMapType) NewMap() Map {
69 var deadcafe = []byte("\xDE\xAD\xCA\xFE")
71 type intMap map[int][]byte
73 func (m intMap) AddItem() {
76 key := rand.Intn(s0 + 1)
77 m[key] = make([]byte, rand.Intn(64<<10))
81 func (m intMap) DelItem() {
88 func (m intMap) GetItem() {
89 key := rand.Intn(len(m))
90 if s, ok := m[key]; ok {
95 func (m intMap) Len() int { return len(m) }
97 func (m intMap) RangeAll() {
106 var wg sync.WaitGroup
107 for _, mt := range mapTypes() {
109 go stressMapType(mt, wg.Done)