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

Function BenchmarkBuildIndex

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

Source from the content-addressed store, hash-verified

86}
87
88func BenchmarkBuildIndex(b *testing.B) {
89 scales := []struct {
90 name string
91 n int
92 }{
93 {"1K", 1_000},
94 {"10K", 10_000},
95 {"100K", 100_000},
96 }
97
98 for _, sc := range scales {
99 b.Run(sc.name, func(b *testing.B) {
100 if sc.n >= 100_000 && testing.Short() {
101 b.Skip("skipping large-scale benchmark")
102 }
103 dir := b.TempDir()
104 generateFileTree(b, dir, sc.n, 42)
105
106 b.ResetTimer()
107 for i := 0; i < b.N; i++ {
108 idx := buildIndex(b, dir)
109 if idx.Len() == 0 {
110 b.Fatal("expected non-empty index")
111 }
112 }
113 b.StopTimer()
114
115 idx := buildIndex(b, dir)
116 b.ReportMetric(float64(idx.Len())/b.Elapsed().Seconds(), "files/sec")
117 })
118 }
119}
120
121func BenchmarkSearch_ByScale(b *testing.B) {
122 queries := []struct {

Callers

nothing calls this directly

Calls 7

generateFileTreeFunction · 0.85
buildIndexFunction · 0.85
SkipMethod · 0.80
FatalMethod · 0.80
RunMethod · 0.65
TempDirMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected