(b *testing.B)
| 507 | } |
| 508 | |
| 509 | func BenchmarkEngine_DatabaseWithLockFreeSlice(b *testing.B) { |
| 510 | type entry struct { |
| 511 | db *database |
| 512 | name string |
| 513 | } |
| 514 | var v atomic.Value |
| 515 | var entries []entry |
| 516 | for _, dn := range testDatabaseNames { |
| 517 | entries = append(entries, entry{name: dn, db: &database{}}) |
| 518 | } |
| 519 | v.Store(entries) |
| 520 | // 2.534 ns |
| 521 | b.RunParallel(func(pb *testing.PB) { |
| 522 | for pb.Next() { |
| 523 | sl := v.Load().([]entry) |
| 524 | for idx := range sl { |
| 525 | if sl[idx].name == "nginx" { |
| 526 | break |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | }) |
| 531 | } |