Skip to content

Commit af635ec

Browse files
committed
make the data sent metric safe against NaN
Signed-off-by: Andres Taylor <[email protected]>
1 parent 2791d33 commit af635ec

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/cmd/vtbenchstat/vtbenchstat.go

+9-13
Original file line numberDiff line numberDiff line change
@@ -190,29 +190,25 @@ func compareTraces(file1, file2 TraceFile) {
190190
for query := range allQueries {
191191
s1, ok1 := summary1[query]
192192
s2, ok2 := summary2[query]
193-
193+
if !(ok1 && ok2) {
194+
continue
195+
}
194196
totalQueries++
195197

196198
printQuery(query, termWidth)
197199
table := tablewriter.NewWriter(os.Stdout)
198200
table.SetHeader([]string{"Metric", file1.Name, file2.Name, "Diff", "% Change"})
199201
table.SetAutoFormatHeaders(false)
200202

201-
if ok1 && ok2 {
202-
routeCallsChange := compareMetric(table, "Route Calls", s1.RouteCalls, s2.RouteCalls)
203-
dataSentChange := compareMetric(table, "Rows Sent", s1.RowsSent, s2.RowsSent)
203+
routeCallsChange := compareMetric(table, "Route Calls", s1.RouteCalls, s2.RouteCalls)
204+
dataSentChange := compareMetric(table, "Rows Sent", s1.RowsSent, s2.RowsSent)
204205

205-
totalRouteCallsChange += routeCallsChange
206+
totalRouteCallsChange += routeCallsChange
207+
if !math.IsNaN(dataSentChange) {
206208
totalDataSentChange += dataSentChange
209+
}
207210

208-
if math.Abs(routeCallsChange) > significantChangeThreshold || math.Abs(dataSentChange) > significantChangeThreshold {
209-
significantChanges++
210-
}
211-
} else if ok1 {
212-
addMissingMetrics(table, s1.RouteCalls, s1.RowsSent)
213-
significantChanges++
214-
} else if ok2 {
215-
addMissingMetrics(table, s2.RouteCalls, s2.RowsSent)
211+
if math.Abs(routeCallsChange) > significantChangeThreshold || math.Abs(dataSentChange) > significantChangeThreshold {
216212
significantChanges++
217213
}
218214

0 commit comments

Comments
 (0)