Commit eecb6a79 authored by Andrew Gerrand's avatar Andrew Gerrand

builder: report run time

dashboard: record run time

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5504054
parent 494e52fe
...@@ -180,6 +180,8 @@ type Result struct { ...@@ -180,6 +180,8 @@ type Result struct {
OK bool OK bool
Log string `datastore:"-"` // for JSON unmarshaling only Log string `datastore:"-"` // for JSON unmarshaling only
LogHash string `datastore:",noindex"` // Key to the Log record. LogHash string `datastore:",noindex"` // Key to the Log record.
RunTime int64 // time to build+test in nanoseconds
} }
func (r *Result) Key(c appengine.Context) *datastore.Key { func (r *Result) Key(c appengine.Context) *datastore.Key {
......
...@@ -111,7 +111,7 @@ func (b *Builder) todo(kind, pkg, goHash string) (rev string, err error) { ...@@ -111,7 +111,7 @@ func (b *Builder) todo(kind, pkg, goHash string) (rev string, err error) {
} }
// recordResult sends build results to the dashboard // recordResult sends build results to the dashboard
func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string) error { func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string, runTime time.Duration) error {
req := obj{ req := obj{
"Builder": b.name, "Builder": b.name,
"PackagePath": pkg, "PackagePath": pkg,
...@@ -119,6 +119,7 @@ func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string) erro ...@@ -119,6 +119,7 @@ func (b *Builder) recordResult(ok bool, pkg, hash, goHash, buildLog string) erro
"GoHash": goHash, "GoHash": goHash,
"OK": ok, "OK": ok,
"Log": buildLog, "Log": buildLog,
"RunTime": runTime,
} }
args := url.Values{"key": {b.key}, "builder": {b.name}} args := url.Values{"key": {b.key}, "builder": {b.name}}
return dash("POST", "result", args, req, nil) return dash("POST", "result", args, req, nil)
......
...@@ -294,7 +294,9 @@ func (b *Builder) buildHash(hash string) (err error) { ...@@ -294,7 +294,9 @@ func (b *Builder) buildHash(hash string) (err error) {
// build // build
logfile := path.Join(workpath, "build.log") logfile := path.Join(workpath, "build.log")
startTime := time.Now()
buildLog, status, err := runLog(b.envv(), logfile, srcDir, *buildCmd) buildLog, status, err := runLog(b.envv(), logfile, srcDir, *buildCmd)
runTime := time.Now().Sub(startTime)
if err != nil { if err != nil {
return fmt.Errorf("%s: %s", *buildCmd, err) return fmt.Errorf("%s: %s", *buildCmd, err)
} }
...@@ -309,11 +311,11 @@ func (b *Builder) buildHash(hash string) (err error) { ...@@ -309,11 +311,11 @@ func (b *Builder) buildHash(hash string) (err error) {
if status != 0 { if status != 0 {
// record failure // record failure
return b.recordResult(false, "", hash, "", buildLog) return b.recordResult(false, "", hash, "", buildLog, runTime)
} }
// record success // record success
if err = b.recordResult(true, "", hash, "", ""); err != nil { if err = b.recordResult(true, "", hash, "", "", runTime); err != nil {
return fmt.Errorf("recordResult: %s", err) return fmt.Errorf("recordResult: %s", err)
} }
...@@ -378,7 +380,7 @@ func (b *Builder) buildPackages(goRoot, goHash string) { ...@@ -378,7 +380,7 @@ func (b *Builder) buildPackages(goRoot, goHash string) {
} }
// record the result // record the result
err = b.recordResult(ok, pkg, hash, goHash, buildLog) err = b.recordResult(ok, pkg, hash, goHash, buildLog, 0)
if err != nil { if err != nil {
log.Printf("buildPackages %s: %v", pkg, err) log.Printf("buildPackages %s: %v", pkg, err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment