Skip to content

Commit 90f9192

Browse files
committed
cmd/go: run benchmarks in sequence
Fixes #5662. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/13650043
1 parent 6706931 commit 90f9192

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/cmd/go/test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,15 @@ func runTest(cmd *Command, args []string) {
446446
}
447447
}
448448

449-
// If we are benchmarking, force everything to
450-
// happen in serial. Could instead allow all the
451-
// builds to run before any benchmarks start,
452-
// but try this for now.
449+
// Force benchmarks to run in serial.
453450
if testBench {
454-
for i, a := range builds {
455-
if i > 0 {
456-
// Make build of test i depend on
457-
// completing the run of test i-1.
458-
a.deps = append(a.deps, runs[i-1])
451+
// The first run must wait for all builds.
452+
// Later runs must wait for the previous run's print.
453+
for i, run := range runs {
454+
if i == 0 {
455+
run.deps = append(run.deps, builds...)
456+
} else {
457+
run.deps = append(run.deps, prints[i-1])
459458
}
460459
}
461460
}
@@ -516,8 +515,8 @@ func contains(x []string, s string) bool {
516515
func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, err error) {
517516
if len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 {
518517
build := &action{p: p}
519-
run := &action{p: p}
520-
print := &action{f: (*builder).notest, p: p, deps: []*action{build}}
518+
run := &action{p: p, deps: []*action{build}}
519+
print := &action{f: (*builder).notest, p: p, deps: []*action{run}}
521520
return build, run, print, nil
522521
}
523522

0 commit comments

Comments
 (0)