@@ -135,15 +135,23 @@ func run(c config) error {
135
135
var ratios []result
136
136
var rows [][]string
137
137
for benchName , headBenchmarks := range headSet {
138
+ var prevBench , headBench * parse.Benchmark
139
+
140
+ if len (headBenchmarks ) > 0 {
141
+ headBench = headBenchmarks [0 ]
142
+ }
143
+ rows = append (rows , generateRow ("HEAD" , headBench ))
144
+
138
145
prevBenchmarks , ok := prevSet [benchName ]
139
146
if ! ok {
147
+ rows = append (rows , []string {benchName , c .base , "-" , "-" })
140
148
continue
141
149
}
142
- if len (headBenchmarks ) == 0 || len (prevBenchmarks ) == 0 {
143
- continue
150
+
151
+ if len (prevBenchmarks ) > 0 {
152
+ prevBench = prevBenchmarks [0 ]
144
153
}
145
- prevBench := prevBenchmarks [0 ]
146
- headBench := headBenchmarks [0 ]
154
+ rows = append (rows , generateRow (c .base , prevBench ))
147
155
148
156
var ratioNsPerOp float64
149
157
if prevBench .NsPerOp != 0 {
@@ -155,9 +163,6 @@ func run(c config) error {
155
163
ratioAllocedBytesPerOp = (float64 (headBench .AllocedBytesPerOp ) - float64 (prevBench .AllocedBytesPerOp )) / float64 (prevBench .AllocedBytesPerOp )
156
164
}
157
165
158
- rows = append (rows , generateRow ("HEAD" , headBench ))
159
- rows = append (rows , generateRow ("HEAD@{1}" , prevBench ))
160
-
161
166
ratios = append (ratios , result {
162
167
Name : benchName ,
163
168
RatioNsPerOp : ratioNsPerOp ,
@@ -177,9 +182,17 @@ func run(c config) error {
177
182
return nil
178
183
}
179
184
180
- func runBenchmark (cmd string , args []string ) (parse.Set , error ) {
181
- out , err := exec .Command (cmd , args ... ).Output ()
185
+ func runBenchmark (cmdStr string , args []string ) (parse.Set , error ) {
186
+ var stderr bytes.Buffer
187
+ cmd := exec .Command (cmdStr , args ... )
188
+ cmd .Stderr = & stderr
189
+
190
+ out , err := cmd .Output ()
182
191
if err != nil {
192
+ if strings .HasSuffix (strings .TrimSpace (stderr .String ()), "no packages to test" ) {
193
+ return parse.Set {}, nil
194
+ }
195
+ log .Println (stderr .String ())
183
196
return nil , xerrors .Errorf ("failed to run '%s %s' command: %w" , cmd , strings .Join (args , " " ), err )
184
197
}
185
198
@@ -274,10 +287,8 @@ func whichScoreToCompare(c []string) comparedScore {
274
287
for _ , cc := range c {
275
288
switch cc {
276
289
case "ns/op" :
277
- fmt .Println ("cpu" )
278
290
comparedScore .nsPerOp = true
279
291
case "B/op" :
280
- fmt .Println ("memory" )
281
292
comparedScore .allocedBytesPerOp = true
282
293
}
283
294
}
0 commit comments