(b *testing.B)
| 282 | } |
| 283 | |
| 284 | func BenchmarkSearch_ConcurrentReads_Throughput(b *testing.B) { |
| 285 | dir := b.TempDir() |
| 286 | generateFileTree(b, dir, 10_000, 42) |
| 287 | idx := buildIndex(b, dir) |
| 288 | snap := idx.Snapshot() |
| 289 | |
| 290 | goroutines := []int{1, 4, 16, 64} |
| 291 | plan := filefinder.NewQueryPlanForTest("handler.go") |
| 292 | maxCands := filefinder.DefaultSearchOptions().MaxCandidates |
| 293 | |
| 294 | for _, g := range goroutines { |
| 295 | b.Run(fmt.Sprintf("goroutines_%d", g), func(b *testing.B) { |
| 296 | b.ResetTimer() |
| 297 | var wg sync.WaitGroup |
| 298 | perGoroutine := b.N / g |
| 299 | if perGoroutine < 1 { |
| 300 | perGoroutine = 1 |
| 301 | } |
| 302 | for gi := 0; gi < g; gi++ { |
| 303 | wg.Add(1) |
| 304 | go func() { |
| 305 | defer wg.Done() |
| 306 | for j := 0; j < perGoroutine; j++ { |
| 307 | _ = filefinder.SearchSnapshotForTest(plan, snap, maxCands) |
| 308 | } |
| 309 | }() |
| 310 | } |
| 311 | wg.Wait() |
| 312 | totalOps := float64(g * perGoroutine) |
| 313 | b.ReportMetric(totalOps/b.Elapsed().Seconds(), "searches/sec") |
| 314 | }) |
| 315 | } |
| 316 | } |
nothing calls this directly
no test coverage detected