1
0
mirror of https://github.com/golang/go synced 2024-11-24 23:37:56 -07:00

builder: report run time

dashboard: record run time

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5504054
This commit is contained in:
Andrew Gerrand 2011-12-21 15:43:12 +11:00
parent 494e52fe1c
commit eecb6a79ff
3 changed files with 9 additions and 4 deletions

View File

@ -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 {

View File

@ -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
"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)

View File

@ -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) {
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) {
} }
// 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)
} }