(b *testing.B)
| 193 | } |
| 194 | |
| 195 | func BenchmarkDeltaUpdate(b *testing.B) { |
| 196 | dir := b.TempDir() |
| 197 | generateFileTree(b, dir, 10_000, 42) |
| 198 | |
| 199 | addCounts := []int{1, 10, 100} |
| 200 | |
| 201 | for _, count := range addCounts { |
| 202 | b.Run(fmt.Sprintf("add_%d_files", count), func(b *testing.B) { |
| 203 | paths := make([]string, count) |
| 204 | for i := range paths { |
| 205 | paths[i] = fmt.Sprintf("injected/dir_%d/newfile_%d.go", i%10, i) |
| 206 | } |
| 207 | b.ResetTimer() |
| 208 | for i := 0; i < b.N; i++ { |
| 209 | b.StopTimer() |
| 210 | idx := buildIndex(b, dir) |
| 211 | b.StartTimer() |
| 212 | for _, p := range paths { |
| 213 | idx.Add(p, 0) |
| 214 | } |
| 215 | } |
| 216 | b.ReportMetric(float64(count), "files_added/op") |
| 217 | }) |
| 218 | } |
| 219 | |
| 220 | b.Run("search_after_100_additions", func(b *testing.B) { |
| 221 | idx := buildIndex(b, dir) |
| 222 | for i := 0; i < 100; i++ { |
| 223 | idx.Add(fmt.Sprintf("injected/extra/file_%d.go", i), 0) |
| 224 | } |
| 225 | snap := idx.Snapshot() |
| 226 | plan := filefinder.NewQueryPlanForTest("handler") |
| 227 | opts := filefinder.DefaultSearchOptions() |
| 228 | |
| 229 | b.ResetTimer() |
| 230 | for i := 0; i < b.N; i++ { |
| 231 | _ = filefinder.SearchSnapshotForTest(plan, snap, opts.MaxCandidates) |
| 232 | } |
| 233 | }) |
| 234 | } |
| 235 | |
| 236 | func BenchmarkMemoryProfile(b *testing.B) { |
| 237 | scales := []struct { |
nothing calls this directly
no test coverage detected