Skip to content

Commit

Permalink
only include deps in AllImportPaths when -r is used
Browse files Browse the repository at this point in the history
It's entirely unnecessary work otherwise.
  • Loading branch information
mvdan committed Nov 18, 2023
1 parent e0926bb commit c4a7182
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ func doBench(pkgs []*Package, buildflags, testflags []string) error {
allPkgs := make(map[string]bool)
for _, pkg := range pkgs {
allPkgs[pkg.ImportPath] = true
for _, dep := range pkg.Deps {
allPkgs[dep] = true
// When including the costs of transitive dependencies,
// we need to collect their init costs as well.
if *recursive {
for _, dep := range pkg.Deps {
allPkgs[dep] = true
}
}

input.BenchPkgs = append(input.BenchPkgs, benchmainPackage{
Expand Down

0 comments on commit c4a7182

Please sign in to comment.