Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: go/src/infra/appengine/test-results/model/full_result.go

Issue 2231393002: test-results: Add merge and trim methods (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: tests: remove unecessary Trim calls Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: go/src/infra/appengine/test-results/model/full_result.go
diff --git a/go/src/infra/appengine/test-results/model/full_result.go b/go/src/infra/appengine/test-results/model/full_result.go
index 0caebf7b5508369acd2c754f4691a730f201d27b..d99463cf5bddd5ef1d64b4fc42b2dd2a848d1f07 100644
--- a/go/src/infra/appengine/test-results/model/full_result.go
+++ b/go/src/infra/appengine/test-results/model/full_result.go
@@ -3,6 +3,7 @@ package model
import (
"encoding/json"
"errors"
+ "math"
"strings"
)
@@ -283,13 +284,20 @@ func (l *FullTestLeaf) AggregateTestLeaf() (AggregateTestLeaf, error) {
var time float64
if l.Runtime != nil {
- time = *l.Runtime
+ time = float64(round(*l.Runtime))
}
ret.Runtimes = []RuntimeSummary{{1, time}}
return ret, nil
}
+func round(f float64) int {
+ if math.Abs(f) < 0.5 {
+ return 0
+ }
+ return int(f + math.Copysign(0.5, f))
+}
+
// MarshalJSON marshals l into JSON.
func (l *FullTestLeaf) MarshalJSON() ([]byte, error) {
aux := testResultAux{fullTestLeafAlias: (*fullTestLeafAlias)(l)}

Powered by Google App Engine
This is Rietveld 408576698