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

Function BenchmarkSearch_ByScale

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

Source from the content-addressed store, hash-verified

119}
120
121func BenchmarkSearch_ByScale(b *testing.B) {
122 queries := []struct {
123 name string
124 query string
125 }{
126 {"exact_basename", "handler.go"},
127 {"short_query", "ha"},
128 {"fuzzy_basename", "hndlr"},
129 {"path_structured", "internal/handler"},
130 {"multi_token", "api handler"},
131 }
132 scales := []struct {
133 name string
134 n int
135 }{
136 {"1K", 1_000},
137 {"10K", 10_000},
138 {"100K", 100_000},
139 }
140
141 for _, sc := range scales {
142 b.Run(sc.name, func(b *testing.B) {
143 if sc.n >= 100_000 && testing.Short() {
144 b.Skip("skipping large-scale benchmark")
145 }
146 dir := b.TempDir()
147 generateFileTree(b, dir, sc.n, 42)
148 idx := buildIndex(b, dir)
149 snap := idx.Snapshot()
150 opts := filefinder.DefaultSearchOptions()
151
152 for _, q := range queries {
153 b.Run(q.name, func(b *testing.B) {
154 p := filefinder.NewQueryPlanForTest(q.query)
155 b.ResetTimer()
156 for i := 0; i < b.N; i++ {
157 _ = filefinder.SearchSnapshotForTest(p, snap, opts.MaxCandidates)
158 }
159 })
160 }
161 })
162 }
163}
164
165func BenchmarkSearch_ConcurrentReads(b *testing.B) {
166 dir := b.TempDir()

Callers

nothing calls this directly

Calls 7

DefaultSearchOptionsFunction · 0.92
generateFileTreeFunction · 0.85
buildIndexFunction · 0.85
SkipMethod · 0.80
SnapshotMethod · 0.80
RunMethod · 0.65
TempDirMethod · 0.65

Tested by

no test coverage detected