(ConcurrentMap)
(b *testing.B)
| 301 | |
| 302 | //(ConcurrentMap) |
| 303 | func BenchmarkPutGet_ConcurrentMap(b *testing.B){ |
| 304 | Map := BaseServer.NewConcurrentMap() |
| 305 | |
| 306 | groups := sync.WaitGroup{} |
| 307 | groups.Add(ThreadNumber) |
| 308 | |
| 309 | b.ResetTimer() |
| 310 | |
| 311 | for j:=0; j < ThreadNumber; j++{ |
| 312 | go func(){ |
| 313 | for i := 0; i < b.N; i++ { |
| 314 | Map.Set(strconv.Itoa(i), "lizhaolong") |
| 315 | Map.Get(strconv.Itoa(i-1)) |
| 316 | } |
| 317 | groups.Done() |
| 318 | }() |
| 319 | } |
| 320 | groups.Wait() |
| 321 | } |
| 322 | |
| 323 | // (Sync.map) |
| 324 | func BenchmarkPutGet_SyncMap(b *testing.B){ |