Skip to content

Commit 2da252e

Browse files
committed
utils: introduce new -Summary option for build.ps1
Add a new `-Summary` option to understand the build times expenditure. This prints a summary at the end of the build time, though should be further refined to include tests, auxiliary operations, and the like. ~~~ Arch Checkout BuildID Elapsed Time ---- -------- ------- ------------ x64 S:\SourceCache\swift-project\swift\tools\swift-inspect swift-inspect 00:00:00.2372939 x64 S:\SourceCache\swift-project\sqlite-3.43.2 sqlite-3.43.2 00:00:00.5062697 x64 S:\SourceCache\swift-project\zlib zlib-1.3 00:00:00.5615253 arm64 S:\SourceCache\swift-project\zlib zlib-1.3 00:00:00.5623726 x86 S:\SourceCache\swift-project\zlib zlib-1.3 00:00:00.6185541 x64 S:\SourceCache\swift-project\swift-system 2 00:00:00.6562858 x64 S:\SourceCache\swift-project\Yams 5 00:00:00.6647429 x64 S:\SourceCache\swift-project\swift-certificates 11 00:00:00.6649416 arm64 S:\SourceCache\swift-project\swift-corelibs-xctest 304 00:00:00.6688467 x64 S:\SourceCache\swift-project\swift-asn1 10 00:00:00.6795648 x64 S:\SourceCache\swift-project\swift-corelibs-xctest 104 00:00:00.6938559 x64 S:\SourceCache\swift-project\swift-argument-parser 6 00:00:00.7351350 x64 S:\SourceCache\swift-project\swift-tools-support-core 3 00:00:00.7400418 x64 S:\SourceCache\swift-project\indexstore-db 15 00:00:00.7402386 x86 S:\SourceCache\swift-project\swift-corelibs-xctest 204 00:00:00.7414125 x64 S:\SourceCache\swift-project\cmark cmark-gfm-0.29.0.gfm.13 00:00:00.7435080 x64 S:\SourceCache\swift-project\swift-crypto 8 00:00:00.7593080 arm64 S:\SourceCache\swift-project\libxml2 libxml2-2.11.5 00:00:00.7659147 x64 S:\SourceCache\swift-project\libxml2 libxml2-2.11.5 00:00:00.7885430 x64 S:\SourceCache\swift-project\sourcekit-lsp 16 00:00:00.8459008 arm64 S:\SourceCache\swift-project\icu\icu4c icu-69.1 00:00:00.8544044 x86 S:\SourceCache\swift-project\libxml2 libxml2-2.11.5 00:00:00.8552676 x64 S:\SourceCache\swift-project\icu\icu4c icu-69.1 00:00:00.8986529 x64 S:\SourceCache\swift-project\curl curl-8.4.0 00:00:00.9157392 arm64 S:\SourceCache\swift-project\curl curl-8.4.0 00:00:00.9292362 x64 S:\SourceCache\swift-project\swift-package-manager 12 00:00:00.9352117 x86 S:\SourceCache\swift-project\icu\icu4c icu-69.1 00:00:00.9890039 x86 S:\SourceCache\swift-project\curl curl-8.4.0 00:00:01.0041779 x64 S:\SourceCache\swift-project\llbuild 4 00:00:01.0835003 arm64 S:\SourceCache\swift-project\swift-corelibs-libdispatch 302 00:00:01.2923527 x64 S:\SourceCache\swift-project\swift-corelibs-libdispatch 102 00:00:01.2940821 x86 S:\SourceCache\swift-project\swift-corelibs-libdispatch 202 00:00:01.3725038 x64 S:\SourceCache\swift-project\swift-docc swift-docc 00:00:01.5638843 x64 S:\SourceCache\swift-project\swift-corelibs-foundation 103 00:00:03.2156545 arm64 S:\SourceCache\swift-project\swift-corelibs-foundation 303 00:00:03.2375292 x86 S:\SourceCache\swift-project\swift-corelibs-foundation 203 00:00:03.3768394 x64 S:\SourceCache\swift-project\swift 101 00:00:03.4123377 x86 S:\SourceCache\swift-project\swift 201 00:00:03.4822752 arm64 S:\SourceCache\swift-project\swift 301 00:00:03.5000946 x64 S:\SourceCache\swift-project\swift-collections 9 00:00:04.1620695 x64 S:\SourceCache\swift-project\swift-format 14 00:00:07.9155136 arm64 S:\SourceCache\swift-project\llvm-project\llvm 300 00:00:08.0239769 x64 S:\SourceCache\swift-project\llvm-project\llvm 100 00:00:08.0504294 x86 S:\SourceCache\swift-project\llvm-project\llvm 200 00:00:08.1190769 x64 S:\SourceCache\swift-project\swift-markdown 13 00:00:12.4397452 x64 S:\SourceCache\swift-project\swift-driver 7 00:00:24.9125831 x64 S:\SourceCache\swift-project\llvm-project\llvm 1 00:01:04.5879144 x64 S:\SourceCache\swift-project\llvm-project\llvm 0 00:01:10.9225001 ~~~
1 parent a037974 commit 2da252e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

utils/build.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ param(
107107
[switch] $Clean,
108108
[switch] $DebugInfo,
109109
[switch] $EnableCaching,
110+
[switch] $Summary,
110111
[switch] $ToBatch
111112
)
112113

@@ -204,6 +205,8 @@ $HostArch = switch ($NativeProcessorArchName) {
204205
default { throw "Unsupported processor architecture" }
205206
}
206207

208+
$TimingData = New-Object System.Collections.Generic.List[System.Object]
209+
207210
function Get-InstallDir($Arch) {
208211
if ($Arch -eq $HostArch) {
209212
$ProgramFilesName = "Program Files"
@@ -760,6 +763,15 @@ function Build-CMakeProject {
760763
Write-Host -ForegroundColor Cyan "[$([DateTime]::Now.ToString("yyyy-MM-dd HH:mm:ss"))] Finished building '$Src' to '$Bin' for arch '$($Arch.ShortName)' in $($Stopwatch.Elapsed)"
761764
Write-Host ""
762765
}
766+
767+
if ($Summary) {
768+
$TimingData.Add([PSCustomObject]@{
769+
Arch = $Arch.ShortName
770+
Checkout = $Src
771+
BuildID = Split-Path -Path $Bin -Leaf
772+
"Elapsed Time" = $Stopwatch.Elapsed.ToString()
773+
})
774+
}
763775
}
764776

765777
function Build-SPMProject {
@@ -811,6 +823,15 @@ function Build-SPMProject {
811823
Write-Host -ForegroundColor Cyan "[$([DateTime]::Now.ToString("yyyy-MM-dd HH:mm:ss"))] Finished building '$Src' to '$Bin' for arch '$($Arch.ShortName)' in $($Stopwatch.Elapsed)"
812824
Write-Host ""
813825
}
826+
827+
if ($Summary) {
828+
$TimingData.Add([PSCustomObject]@{
829+
Arch = $Arch.ShortName
830+
Checkout = $Src
831+
BuildID = Split-Path -Path $Bin -Leaf
832+
"Elapsed Time" = $Stopwatch.Elapsed.ToString()
833+
})
834+
}
814835
}
815836

816837
function Build-WiXProject() {
@@ -1860,6 +1881,10 @@ if ($Stage) {
18601881
Stage-BuildArtifacts $HostArch
18611882
}
18621883

1884+
if ($Summary) {
1885+
$TimingData | Select Arch,Checkout,BuildID,"Elapsed Time" | Sort -Descending -Property "Elapsed Time" | Format-Table -AutoSize
1886+
}
1887+
18631888
if ($Test -ne $null -and (Compare-Object $Test @("clang", "lld", "lldb", "llvm", "swift") -PassThru -IncludeEqual -ExcludeDifferent) -ne $null) {
18641889
$Tests = @{
18651890
"-TestClang" = $Test -contains "clang";

0 commit comments

Comments
 (0)