Show estimated build end time during build
Ninja delivers estimated total build time and critical path time from previous ninja log. Bug: 292304818 Test: check if ETA shows Change-Id: I014caaa3e8222a53c8822616b2ae31b88a3b0310
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -178,7 +179,28 @@ func (n *NinjaReader) run() {
|
||||
// msgChan is closed
|
||||
break
|
||||
}
|
||||
// Ignore msg.BuildStarted
|
||||
|
||||
if msg.BuildStarted != nil {
|
||||
parallelism := uint32(runtime.NumCPU())
|
||||
if msg.BuildStarted.GetParallelism() > 0 {
|
||||
parallelism = msg.BuildStarted.GetParallelism()
|
||||
}
|
||||
// It is estimated from total time / parallelism assumming the build is packing enough.
|
||||
estimatedDurationFromTotal := time.Duration(msg.BuildStarted.GetEstimatedTotalTime()/parallelism) * time.Millisecond
|
||||
// It is estimated from critical path time which is useful for small size build.
|
||||
estimatedDurationFromCriticalPath := time.Duration(msg.BuildStarted.GetCriticalPathTime()) * time.Millisecond
|
||||
// Select the longer one.
|
||||
estimatedDuration := max(estimatedDurationFromTotal, estimatedDurationFromCriticalPath)
|
||||
|
||||
if estimatedDuration > 0 {
|
||||
n.status.SetEstimatedTime(time.Now().Add(estimatedDuration))
|
||||
n.status.Verbose(fmt.Sprintf("parallelism: %d, estimiated from total time: %s, critical path time: %s",
|
||||
parallelism,
|
||||
estimatedDurationFromTotal,
|
||||
estimatedDurationFromCriticalPath))
|
||||
|
||||
}
|
||||
}
|
||||
if msg.TotalEdges != nil {
|
||||
n.status.SetTotalActions(int(msg.TotalEdges.GetTotalEdges()))
|
||||
}
|
||||
|
Reference in New Issue
Block a user