(b *testing.B)
| 216 | } |
| 217 | |
| 218 | func BenchmarkXidmapReadsRandom(b *testing.B) { |
| 219 | conn, err := x.SetupConnection(testutil.GetSockAddrZero(), nil, false) |
| 220 | if err != nil { |
| 221 | b.Fatalf("Error setting up connection: %s", err.Error()) |
| 222 | } |
| 223 | |
| 224 | var N = 1000000 |
| 225 | buf := make([]byte, 32) |
| 226 | var list [][]byte |
| 227 | xidmap := New(getTestXidmapOpts(conn, nil)) |
| 228 | defer xidmap.Flush() |
| 229 | for i := 0; i < N; i++ { |
| 230 | rand.Read(buf) |
| 231 | list = append(list, buf) |
| 232 | xidmap.AssignUid(string(buf)) |
| 233 | } |
| 234 | b.ResetTimer() |
| 235 | |
| 236 | b.RunParallel(func(pb *testing.PB) { |
| 237 | for pb.Next() { |
| 238 | xidmap.AssignUid(string(list[rand.Intn(len(list))])) |
| 239 | } |
| 240 | }) |
| 241 | } |
nothing calls this directly
no test coverage detected