MCPcopy Index your code
hub / github.com/coder/coder / BenchmarkSearch_ConcurrentReads_Throughput

Function BenchmarkSearch_ConcurrentReads_Throughput

agent/filefinder/bench_test.go:284–316  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

282}
283
284func 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}

Callers

nothing calls this directly

Calls 9

DefaultSearchOptionsFunction · 0.92
generateFileTreeFunction · 0.85
buildIndexFunction · 0.85
SnapshotMethod · 0.80
TempDirMethod · 0.65
RunMethod · 0.65
AddMethod · 0.65
WaitMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected