Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/XCLogParser/parser/BuildStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public enum DetailStepType: String, Encodable {
switch signature {
case Prefix("CompileC "):
return .cCompilation
case Prefix("CompileSwift "):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since which Xcode version was this introduced?

case Prefix("SwiftCompile "):
return .swiftCompilation
case Prefix("Ld "):
return .linker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extension IDEActivityLogSection {
public func getSwiftIndividualSteps(buildStep: BuildStep,
parentCommandDetailDesc: String,
currentIndex: inout Int) -> [BuildStep]? {
let pattern = #"^CompileSwift\s\w+\s\w+\s.+\.swift\s"#
let pattern = #"^SwiftCompile\s\w+\s\w+\s.+\.swift\s"#
guard commandDetailDesc.range(of: pattern, options: .regularExpression) == nil else {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCLogParser/parser/ParserBuildSteps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public final class ParserBuildSteps {
}()

lazy var swiftcArchRegexp: NSRegularExpression? = {
let pattern = "^CompileSwift normal (\\w*) "
let pattern = "^SwiftCompile normal (\\w*) "
return NSRegularExpression.fromPattern(pattern)
}()

Expand Down
2 changes: 1 addition & 1 deletion Sources/XCLogParser/parser/SwiftFunctionTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import Foundation

/// Represents the time it took to the Swift Compiler to compile a function
public struct SwiftFunctionTime: Encodable {
public struct SwiftFunctionTime: Encodable, Hashable {
/// URL of the file where the function is
public let file: String

Expand Down
2 changes: 1 addition & 1 deletion Sources/XCLogParser/parser/SwiftTypeCheck.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import Foundation

/// Represents the time it took to the Swift Compiler to type check an expression
public struct SwiftTypeCheck: Encodable {
public struct SwiftTypeCheck: Encodable, Hashable {

/// URL of the file where the function is
public let file: String
Expand Down
45 changes: 22 additions & 23 deletions Sources/XCLogParser/reporter/HtmlReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,40 +203,39 @@
let steps = build.subSteps.map { $0.subSteps }.joined()
let aggretatedAndSwiftSteps = steps.filter { !$0.fetchedFromCache &&
($0.detailStepType == .swiftCompilation || $0.detailStepType == .swiftAggregatedCompilation) }
var swiftFunctionTimes: [SwiftFunctionTime] = []
var swiftTypeCheckTimes: [SwiftTypeCheck] = []
var _swiftFunctionTimes: Set<SwiftFunctionTime> = []

Check failure on line 206 in Sources/XCLogParser/reporter/HtmlReporter.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Variable name should only contain alphanumeric characters: '_swiftFunctionTimes' (identifier_name)
var _swiftTypeCheckTimes: Set<SwiftTypeCheck> = []

Check failure on line 207 in Sources/XCLogParser/reporter/HtmlReporter.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Variable name should only contain alphanumeric characters: '_swiftTypeCheckTimes' (identifier_name)
var swiftSteps: [BuildStep] = []

aggretatedAndSwiftSteps.forEach { step in
if step.detailStepType == .swiftAggregatedCompilation {
let swiftSubSteps = step.subSteps.filter { $0.detailStepType == .swiftCompilation}
.map { subStep in
subStep.with(parentIdentifier: step.parentIdentifier)
}
swiftSteps.append(contentsOf: swiftSubSteps)
let functions = swiftSubSteps
.compactMap { $0.swiftFunctionTimes }
.joined()
let typeChecks = swiftSubSteps
.compactMap { $0.swiftTypeCheckTimes }
.joined()
swiftFunctionTimes.append(contentsOf: functions)
swiftTypeCheckTimes.append(contentsOf: typeChecks)
} else {
swiftSteps.append(step)
if let functions = step.swiftFunctionTimes {
swiftFunctionTimes.append(contentsOf: functions)
}
if let typeChecks = step.swiftTypeCheckTimes {
swiftTypeCheckTimes.append(contentsOf: typeChecks)
let swiftSubSteps = step.subSteps.filter { $0.detailStepType == .swiftCompilation}
.map { subStep in
subStep.with(parentIdentifier: step.parentIdentifier)
}
swiftSteps.append(contentsOf: swiftSubSteps)
let functions = swiftSubSteps
.compactMap { $0.swiftFunctionTimes }
.joined()
let typeChecks = swiftSubSteps
.compactMap { $0.swiftTypeCheckTimes }
.joined()
if let functionTimes = step.swiftFunctionTimes {
functionTimes.forEach { _swiftFunctionTimes.insert($0) }
}
if let typeCheckTimes = step.swiftTypeCheckTimes {
typeCheckTimes.forEach { _swiftTypeCheckTimes.insert($0) }
}
functions.forEach { _swiftFunctionTimes.insert($0) }
typeChecks.forEach { _swiftTypeCheckTimes.insert($0) }
}

swiftSteps.sort { $0.compilationDuration > $1.compilationDuration }
let cSteps = steps.filter { !$0.fetchedFromCache && $0.detailStepType == .cCompilation }
.sorted { $0.compilationDuration > $1.compilationDuration }

var swiftFunctionTimes: [SwiftFunctionTime] = Array(_swiftFunctionTimes)
var swiftTypeCheckTimes: [SwiftTypeCheck] = Array(_swiftTypeCheckTimes)

swiftFunctionTimes.sort { $0.durationMS > $1.durationMS }
let topFunctions = Array(swiftFunctionTimes.prefix(Self.maxSwifTypeChecks))

Expand Down
4 changes: 2 additions & 2 deletions Tests/XCLogParserTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ CompileSwift normal x86_64 (in target 'Alamofire' from project 'Pods')
lazy var fakeSwiftCompilation: IDEActivityLogSection = {
return IDEActivityLogSection(sectionType: 1,
domainType: "",
title: "CompileSwift",
signature: "CompileSwift normal x86_64",
title: "SwiftCompile",
signature: "SwiftCompile normal x86_64",
timeStartedRecording: 1.0,
timeStoppedRecording: 2.0,
subSections: [],
Expand Down