Select module files with ancestor boundary lookups
This commit is contained in:
38
internal/validation/scope_performance_test.go
Normal file
38
internal/validation/scope_performance_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit/internal/git"
|
||||
)
|
||||
|
||||
func BenchmarkSelectInputEntriesByModuleCount(b *testing.B) {
|
||||
const retainedFiles = 20000
|
||||
for _, boundaries := range []int{0, 1000, 4000} {
|
||||
b.Run(fmt.Sprintf("boundaries=%d", boundaries), func(b *testing.B) {
|
||||
entries := make([]git.TreeEntry, 0, retainedFiles+2*boundaries)
|
||||
entries = append(entries, git.TreeEntry{Path: "go.mod", Type: "blob", Mode: "100644"})
|
||||
for file := 1; file < retainedFiles; file++ {
|
||||
entries = append(entries, git.TreeEntry{Path: fmt.Sprintf("source/file-%06d.txt", file), Type: "blob", Mode: "100644"})
|
||||
}
|
||||
for module := 0; module < boundaries; module++ {
|
||||
directory := fmt.Sprintf("modules/unit-%06d", module)
|
||||
entries = append(entries,
|
||||
git.TreeEntry{Path: directory + "/go.mod", Type: "blob", Mode: "100644"},
|
||||
git.TreeEntry{Path: directory + "/source.go", Type: "blob", Mode: "100644"})
|
||||
}
|
||||
byPath := make(map[string]int, len(entries))
|
||||
for i, entry := range entries {
|
||||
byPath[entry.Path] = i
|
||||
}
|
||||
b.ReportAllocs()
|
||||
for b.Loop() {
|
||||
selected, err := selectInputEntries(entries, byPath, ".", []string{})
|
||||
if err != nil || len(selected) != retainedFiles {
|
||||
b.Fatalf("selected %d files, error=%v; want %d", len(selected), err, retainedFiles)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user