|
8 | 8 | "bytes" |
9 | 9 | "net/http" |
10 | 10 | "net/http/httptest" |
| 11 | + "testing" |
11 | 12 | "time" |
12 | 13 |
|
13 | 14 | "github.com/NVIDIA/aistore/api/apc" |
@@ -291,3 +292,75 @@ var _ = Describe("Notifications xaction test", func() { |
291 | 292 | }) |
292 | 293 | }) |
293 | 294 | }) |
| 295 | + |
| 296 | +func BenchmarkShardedAdd(b *testing.B) { |
| 297 | + cos.InitShortID(0) |
| 298 | + n := ¬ifs{ |
| 299 | + nls: newListeners(), |
| 300 | + fin: newListeners(), |
| 301 | + } |
| 302 | + smap := &smapX{} |
| 303 | + targets := make(meta.NodeMap, 1) |
| 304 | + targets["target1"] = &meta.Snode{DaeID: "target1"} |
| 305 | + |
| 306 | + b.ResetTimer() |
| 307 | + for range b.N { |
| 308 | + xid := cos.GenUUID() |
| 309 | + nl := xact.NewXactNL(xid, apc.ActECEncode, &smap.Smap, targets) |
| 310 | + n.nls.add(nl, false) |
| 311 | + } |
| 312 | +} |
| 313 | + |
| 314 | +func BenchmarkShardedEntry(b *testing.B) { |
| 315 | + cos.InitShortID(0) |
| 316 | + n := ¬ifs{ |
| 317 | + nls: newListeners(), |
| 318 | + fin: newListeners(), |
| 319 | + } |
| 320 | + smap := &smapX{} |
| 321 | + targets := make(meta.NodeMap, 1) |
| 322 | + targets["target1"] = &meta.Snode{DaeID: "target1"} |
| 323 | + |
| 324 | + // Seed with listeners |
| 325 | + xids := make([]string, 1000) |
| 326 | + for i := range xids { |
| 327 | + xid := cos.GenUUID() |
| 328 | + xids[i] = xid |
| 329 | + nl := xact.NewXactNL(xid, apc.ActECEncode, &smap.Smap, targets) |
| 330 | + n.nls.add(nl, false) |
| 331 | + } |
| 332 | + |
| 333 | + b.ResetTimer() |
| 334 | + for i := range b.N { |
| 335 | + xid := xids[i%len(xids)] |
| 336 | + _, _ = n.nls.entry(xid) |
| 337 | + } |
| 338 | +} |
| 339 | + |
| 340 | +func BenchmarkShardedConcurrentMixed(b *testing.B) { |
| 341 | + cos.InitShortID(0) |
| 342 | + n := ¬ifs{ |
| 343 | + nls: newListeners(), |
| 344 | + fin: newListeners(), |
| 345 | + } |
| 346 | + smap := &smapX{} |
| 347 | + targets := make(meta.NodeMap, 1) |
| 348 | + targets["target1"] = &meta.Snode{DaeID: "target1"} |
| 349 | + |
| 350 | + b.ResetTimer() |
| 351 | + b.RunParallel(func(pb *testing.PB) { |
| 352 | + for pb.Next() { |
| 353 | + xid := cos.GenUUID() |
| 354 | + nl := xact.NewXactNL(xid, apc.ActECEncode, &smap.Smap, targets) |
| 355 | + |
| 356 | + // Add |
| 357 | + n.nls.add(nl, false) |
| 358 | + |
| 359 | + // Lookup |
| 360 | + _, _ = n.nls.entry(xid) |
| 361 | + |
| 362 | + // Delete |
| 363 | + n.nls.del(nl, false) |
| 364 | + } |
| 365 | + }) |
| 366 | +} |
0 commit comments