Skip to content

Commit 644462c

Browse files
authored
utils: Improve build.ps1 build summary report. (#80026)
* utils: Display total time taken in build Summary. * utils: Add % to summary data in build.ps1. * Cleanup and formatting.
1 parent 2f60c73 commit 644462c

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

utils/build.ps1

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,40 @@ function Add-TimingData {
397397
Arch = $Arch
398398
Platform = $Platform
399399
"Build Step" = $BuildStep
400-
"Elapsed Time" = $ElapsedTime.ToString()
400+
"Elapsed Time" = $ElapsedTime
401401
})
402402
}
403403

404404
function Write-Summary {
405405
Write-Host "Summary:" -ForegroundColor Cyan
406406

407-
# Sort timing data by elapsed time (descending)
408-
$TimingData `
409-
| Select-Object "Build Step",Platform,Arch,"Elapsed Time" `
410-
| Sort-Object -Descending -Property "Elapsed Time" `
411-
| Format-Table -AutoSize
407+
$TotalTime = [TimeSpan]::Zero
408+
foreach ($Entry in $TimingData) {
409+
$TotalTime = $TotalTime.Add($Entry."Elapsed Time")
410+
}
411+
412+
$SortedData = $TimingData | ForEach-Object {
413+
$Percentage = [math]::Round(($_.("Elapsed Time").TotalSeconds / $TotalTime.TotalSeconds) * 100, 1)
414+
$FormattedTime = "{0:hh\:mm\:ss\.ff}" -f $_."Elapsed Time"
415+
[PSCustomObject]@{
416+
"Build Step" = $_."Build Step"
417+
Platform = $_.Platform
418+
Arch = $_.Arch
419+
"Elapsed Time" = $FormattedTime
420+
"%" = "$Percentage%"
421+
}
422+
} | Sort-Object -Descending -Property "%"
423+
424+
$FormattedTotalTime = "{0:hh\:mm\:ss\.ff}" -f $TotalTime
425+
$TotalRow = [PSCustomObject]@{
426+
"Build Step" = "TOTAL"
427+
Platform = ""
428+
Arch = ""
429+
"Elapsed Time" = $FormattedTotalTime
430+
"%" = "100.0%"
431+
}
432+
433+
@($SortedData) + $TotalRow | Format-Table -AutoSize
412434
}
413435

414436
function Get-AndroidNDK {

0 commit comments

Comments
 (0)