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

Function BenchmarkSearch_ConcurrentReads

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

Source from the content-addressed store, hash-verified

163}
164
165func BenchmarkSearch_ConcurrentReads(b *testing.B) {
166 dir := b.TempDir()
167 generateFileTree(b, dir, 10_000, 42)
168
169 logger := slogtest.Make(b, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelError)
170 ctx := context.Background()
171 eng := filefinder.NewEngine(logger)
172 require.NoError(b, eng.AddRoot(ctx, dir))
173 b.Cleanup(func() { _ = eng.Close() })
174
175 opts := filefinder.DefaultSearchOptions()
176 goroutines := []int{1, 4, 16, 64}
177
178 for _, g := range goroutines {
179 b.Run(fmt.Sprintf("goroutines_%d", g), func(b *testing.B) {
180 b.SetParallelism(g)
181 b.ResetTimer()
182 b.RunParallel(func(pb *testing.PB) {
183 for pb.Next() {
184 results, err := eng.Search(ctx, "handler", opts)
185 if err != nil {
186 b.Fatal(err)
187 }
188 _ = results
189 }
190 })
191 })
192 }
193}
194
195func BenchmarkDeltaUpdate(b *testing.B) {
196 dir := b.TempDir()

Callers

nothing calls this directly

Calls 11

AddRootMethod · 0.95
CloseMethod · 0.95
SearchMethod · 0.95
NewEngineFunction · 0.92
DefaultSearchOptionsFunction · 0.92
generateFileTreeFunction · 0.85
FatalMethod · 0.80
TempDirMethod · 0.65
CleanupMethod · 0.65
RunMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected