(b *testing.B)
| 119 | } |
| 120 | |
| 121 | func 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 | |
| 165 | func BenchmarkSearch_ConcurrentReads(b *testing.B) { |
| 166 | dir := b.TempDir() |
nothing calls this directly
no test coverage detected