Skip to content

Commit af5ec3e

Browse files
authored
Merge pull request #80533 from hamishknight/gen-time
[xcodegen] Print the time taken to generate
2 parents 6f68a86 + 063341b commit af5ec3e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import ArgumentParser
14-
import Darwin
14+
import Foundation
1515
import SwiftXcodeGen
1616

1717
@main
@@ -399,14 +399,27 @@ struct SwiftXcodegen: AsyncParsableCommand, Sendable {
399399
try lldbLLVMWorkspace.write("LLDB+LLVM", into: outputDir)
400400
}
401401
}
402-
showCaveatsIfNeeded()
402+
}
403+
404+
func printingTimeTaken<T>(_ fn: () async throws -> T) async rethrows -> T {
405+
let start = Date()
406+
let result = try await fn()
407+
408+
// Note we don't print the time taken when we fail.
409+
let delta = Date().timeIntervalSince(start)
410+
log.info("Successfully generated in \(Int((delta * 1000).rounded()))ms")
411+
412+
return result
403413
}
404414

405415
func run() async {
406416
// Set the log level
407417
log.logLevel = .init(self.logLevel ?? (self.quiet ? .warning : .info))
408418
do {
409-
try await generate()
419+
try await printingTimeTaken {
420+
try await generate()
421+
}
422+
showCaveatsIfNeeded()
410423
} catch {
411424
log.error("\(error)")
412425
}

0 commit comments

Comments
 (0)