]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: run benchmarks in sequence
authorRuss Cox <rsc@golang.org>
Tue, 10 Sep 2013 18:43:21 +0000 (14:43 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 10 Sep 2013 18:43:21 +0000 (14:43 -0400)
Fixes #5662.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13650043

src/cmd/go/test.go

index 2d5557e65e9fabfc6852c6a8c856a77e42d8d06d..3b79e24285b5e1357dbe6f9cc2ea24a7d7bbab0c 100644 (file)
@@ -446,16 +446,15 @@ func runTest(cmd *Command, args []string) {
                }
        }
 
-       // If we are benchmarking, force everything to
-       // happen in serial.  Could instead allow all the
-       // builds to run before any benchmarks start,
-       // but try this for now.
+       // Force benchmarks to run in serial.
        if testBench {
-               for i, a := range builds {
-                       if i > 0 {
-                               // Make build of test i depend on
-                               // completing the run of test i-1.
-                               a.deps = append(a.deps, runs[i-1])
+               // The first run must wait for all builds.
+               // Later runs must wait for the previous run's print.
+               for i, run := range runs {
+                       if i == 0 {
+                               run.deps = append(run.deps, builds...)
+                       } else {
+                               run.deps = append(run.deps, prints[i-1])
                        }
                }
        }
@@ -516,8 +515,8 @@ func contains(x []string, s string) bool {
 func (b *builder) test(p *Package) (buildAction, runAction, printAction *action, err error) {
        if len(p.TestGoFiles)+len(p.XTestGoFiles) == 0 {
                build := &action{p: p}
-               run := &action{p: p}
-               print := &action{f: (*builder).notest, p: p, deps: []*action{build}}
+               run := &action{p: p, deps: []*action{build}}
+               print := &action{f: (*builder).notest, p: p, deps: []*action{run}}
                return build, run, print, nil
        }