diff --git a/utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift b/utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift index 854dc524c721..37d1bb5d0cec 100644 --- a/utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift +++ b/utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift @@ -11,7 +11,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import Darwin +import Foundation import SwiftXcodeGen @main @@ -399,14 +399,27 @@ struct SwiftXcodegen: AsyncParsableCommand, Sendable { try lldbLLVMWorkspace.write("LLDB+LLVM", into: outputDir) } } - showCaveatsIfNeeded() + } + + func printingTimeTaken(_ fn: () async throws -> T) async rethrows -> T { + let start = Date() + let result = try await fn() + + // Note we don't print the time taken when we fail. + let delta = Date().timeIntervalSince(start) + log.info("Successfully generated in \(Int((delta * 1000).rounded()))ms") + + return result } func run() async { // Set the log level log.logLevel = .init(self.logLevel ?? (self.quiet ? .warning : .info)) do { - try await generate() + try await printingTimeTaken { + try await generate() + } + showCaveatsIfNeeded() } catch { log.error("\(error)") }