MCPcopy Create free account
hub / github.com/Super-long/ChubbyGo / BenchmarkGetKey_BaseMap

Function BenchmarkGetKey_BaseMap

MapPerformanceTest/test_test.go:131–158  ·  view source on GitHub ↗

*2.--------------测试Get操作--------------*/ 读取一个存在的key (BaseMap)

(b *testing.B)

Source from the content-addressed store, hash-verified

129
130//(BaseMap)
131func BenchmarkGetKey_BaseMap(b *testing.B){
132 Map := BaseServer.NewBaseMap()
133
134 groups := sync.WaitGroup{}
135 groups.Add(ThreadNumber)
136
137 rand.Seed(time.Now().Unix())
138 // 可能产生(64,128)个键
139 KeyNumber := rand.Intn(63)
140 KeyNumber += 64
141 for i:=0; i<KeyNumber; i++{
142 TempWord := "x " + strconv.Itoa(i) + " y"
143 Map.BaseStore(TempWord, "lizhaolong")
144 }
145
146 b.ResetTimer()
147
148 for j:=0; j < ThreadNumber; j++{
149 go func(){
150 for i := 0; i < b.N; i++ {
151 TempWord := "x " + strconv.Itoa(i%KeyNumber) + " y"
152 Map.BaseGet(TempWord)
153 }
154 groups.Done()
155 }()
156 }
157 groups.Wait()
158}
159
160//(ConcurrentMap)
161func BenchmarkGetKey_ConcurrentMap(b *testing.B){

Callers

nothing calls this directly

Calls 2

BaseStoreMethod · 0.95
BaseGetMethod · 0.95

Tested by

no test coverage detected