*3.--------------测试并发Get,put操作--------------*/ (BaseMap)
(b *testing.B)
| 280 | |
| 281 | //(BaseMap) |
| 282 | func BenchmarkPutGet_BaseMap(b *testing.B){ |
| 283 | Map := BaseServer.NewBaseMap() |
| 284 | |
| 285 | groups := sync.WaitGroup{} |
| 286 | groups.Add(ThreadNumber) |
| 287 | |
| 288 | b.ResetTimer() |
| 289 | |
| 290 | for j:=0; j < ThreadNumber; j++{ |
| 291 | go func(){ |
| 292 | for i := 0; i < b.N; i++ { |
| 293 | Map.BaseStore(strconv.Itoa(i), "lizhaolong") |
| 294 | Map.BaseGet(strconv.Itoa(i-1)) |
| 295 | } |
| 296 | groups.Done() |
| 297 | }() |
| 298 | } |
| 299 | groups.Wait() |
| 300 | } |
| 301 | |
| 302 | //(ConcurrentMap) |
| 303 | func BenchmarkPutGet_ConcurrentMap(b *testing.B){ |