diff options
author | 2022-12-07 21:57:38 +0000 | |
---|---|---|
committer | 2022-12-22 20:13:56 +0000 | |
commit | 6614d9cba39ca6cb5237f17780534cbe7dad0e24 (patch) | |
tree | 44842e776300fb071d1049638bd32c6be4e6c159 /ui/metrics | |
parent | 62e4fe15dce5a158099c45767a7bb2283867725d (diff) |
Add upload-only mode and manual build-started-time flag.
This involved refactoring much of the main method in soong_ui/main.
Test: b build libcore:all
Test: use the build-time started flag and verify via printf that
it's the same across upload.go and metrics.SetBuildDateTimestamp()
Change-Id: Id7fe256337e8ee6c40542eba662c0eadb38e9674
Diffstat (limited to 'ui/metrics')
-rw-r--r-- | ui/metrics/metrics.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ui/metrics/metrics.go b/ui/metrics/metrics.go index ce2d94667..717530c47 100644 --- a/ui/metrics/metrics.go +++ b/ui/metrics/metrics.go @@ -32,13 +32,13 @@ package metrics // of what an event is and how the metrics system is a stack based system. import ( + "fmt" "os" "runtime" "strings" "time" "android/soong/shared" - "google.golang.org/protobuf/proto" soong_metrics_proto "android/soong/ui/metrics/metrics_proto" @@ -223,6 +223,17 @@ func (m *Metrics) SetBuildDateTime(buildTimestamp time.Time) { m.metrics.BuildDateTimestamp = proto.Int64(buildTimestamp.UnixNano() / int64(time.Second)) } +func (m *Metrics) UpdateTotalRealTime(data []byte) error { + if err := proto.Unmarshal(data, &m.metrics); err != nil { + return fmt.Errorf("Failed to unmarshal proto", err) + } + startTime := *m.metrics.Total.StartTime + endTime := uint64(time.Now().UnixNano()) + + *m.metrics.Total.RealTime = *proto.Uint64(endTime - startTime) + return nil +} + // SetBuildCommand adds the build command specified by the user to the // list of collected metrics. func (m *Metrics) SetBuildCommand(cmd []string) { |