Skip to content

Commit 4b007f1

Browse files
author
Robert Gummesson
authored
Merge pull request #39 from RobertGummesson/count-references
Count references
2 parents 835d52b + c585292 commit 4b007f1

6 files changed

Lines changed: 68 additions & 14 deletions

File tree

BuildTimeAnalyzer/CMCompileMeasure.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ struct CMCompileMeasure {
1414
var path: String
1515
var code: String
1616
var filename: String
17+
var references: Int
1718

1819
private var locationArray: [Int]
1920

@@ -33,7 +34,7 @@ struct CMCompileMeasure {
3334
return "\(time)ms"
3435
}
3536

36-
init?(time: Double, rawPath: String, code: String) {
37+
init?(time: Double, rawPath: String, code: String, references: Int) {
3738
let untrimmedFilename = rawPath.characters.split("/").map(String.init).last
3839

3940
guard let filepath = rawPath.characters.split(":").map(String.init).first else { return nil }
@@ -48,6 +49,7 @@ struct CMCompileMeasure {
4849
self.path = filepath
4950
self.filename = filename
5051
self.locationArray = locations
52+
self.references = references
5153
}
5254

5355
subscript(column: Int) -> String {
@@ -57,6 +59,8 @@ struct CMCompileMeasure {
5759
return timeString
5860
case 1:
5961
return fileInfo
62+
case 2:
63+
return "\(references)"
6064
default:
6165
return code
6266
}

BuildTimeAnalyzer/CMLogProcessor.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ extension CMLogProcessorProtocol {
6060
let value = text.substringFromIndex(text.startIndex.advancedBy(match.range.length - 1))
6161
if var rawMeasure = rawMeasures[value] {
6262
rawMeasure.time += time
63+
rawMeasure.references += 1
6364
rawMeasures[value] = rawMeasure
6465
} else {
6566
rawMeasures[value] = CMRawMeasure(time: time, text: value)
@@ -88,7 +89,7 @@ extension CMLogProcessorProtocol {
8889
var result: [CMCompileMeasure] = []
8990
for entry in unprocessedResult {
9091
let code = entry.text.characters.split("\t").map(String.init)
91-
if code.count >= 2, let measure = CMCompileMeasure(time: entry.time, rawPath: code[0], code: trimPrefixes(code[1])) {
92+
if code.count >= 2, let measure = CMCompileMeasure(time: entry.time, rawPath: code[0], code: trimPrefixes(code[1]), references: entry.references) {
9293
result.append(measure)
9394
}
9495
}

BuildTimeAnalyzer/CMRawMeasure.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import Foundation
1111
struct CMRawMeasure {
1212
var time: Double
1313
var text: String
14+
var references: Int
15+
16+
init(time: Double, text: String) {
17+
self.time = time
18+
self.text = text
19+
self.references = 1
20+
}
1421
}
1522

1623
// MARK: Equatable

BuildTimeAnalyzer/CMResultWindow.xib

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<window title="Build Time Analyzer" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
2424
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
2525
<rect key="contentRect" x="196" y="240" width="800" height="323"/>
26-
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
26+
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
2727
<value key="minSize" type="size" width="800" height="323"/>
2828
<view key="contentView" id="EiT-Mj-1SZ">
2929
<rect key="frame" x="0.0" y="0.0" width="800" height="323"/>
@@ -36,14 +36,14 @@
3636
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3737
<subviews>
3838
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="faZ-Wk-Rhw" viewBased="YES" id="z0w-Vo-Edp">
39-
<rect key="frame" x="0.0" y="0.0" width="808" height="229"/>
39+
<rect key="frame" x="0.0" y="0.0" width="914" height="229"/>
4040
<autoresizingMask key="autoresizingMask"/>
4141
<size key="intercellSpacing" width="3" height="2"/>
4242
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
4343
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
4444
<tableColumns>
45-
<tableColumn width="60" minWidth="40" maxWidth="1000" id="UC7-3Q-SDN">
46-
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Time">
45+
<tableColumn width="90" minWidth="40" maxWidth="1000" id="UC7-3Q-SDN">
46+
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Cumulative time">
4747
<font key="font" metaFont="smallSystem"/>
4848
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
4949
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
@@ -56,11 +56,11 @@
5656
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
5757
<prototypeCellViews>
5858
<tableCellView identifier="Cell0" id="tLe-KL-ZJB">
59-
<rect key="frame" x="1" y="1" width="60" height="17"/>
59+
<rect key="frame" x="1" y="1" width="90" height="17"/>
6060
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
6161
<subviews>
6262
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="2iW-se-Q50">
63-
<rect key="frame" x="-2" y="0.0" width="64" height="17"/>
63+
<rect key="frame" x="-2" y="0.0" width="94" height="17"/>
6464
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table " id="toV-TN-DId">
6565
<font key="font" metaFont="system"/>
6666
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -94,7 +94,7 @@
9494
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
9595
<prototypeCellViews>
9696
<tableCellView identifier="Cell1" id="UWh-g1-vp4">
97-
<rect key="frame" x="64" y="1" width="250" height="17"/>
97+
<rect key="frame" x="94" y="1" width="250" height="17"/>
9898
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
9999
<subviews>
100100
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="IxV-hN-wNj">
@@ -118,6 +118,43 @@
118118
</tableCellView>
119119
</prototypeCellViews>
120120
</tableColumn>
121+
<tableColumn identifier="" width="73" minWidth="10" maxWidth="3.4028234663852886e+38" id="dzg-I7-2OR">
122+
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Occurrences">
123+
<font key="font" metaFont="smallSystem"/>
124+
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
125+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
126+
</tableHeaderCell>
127+
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="Zq5-bA-qFO">
128+
<font key="font" metaFont="system"/>
129+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
130+
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
131+
</textFieldCell>
132+
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
133+
<prototypeCellViews>
134+
<tableCellView identifier="Cell2" id="wX5-ni-A1q">
135+
<rect key="frame" x="347" y="1" width="73" height="17"/>
136+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
137+
<subviews>
138+
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Enk-R3-LoW">
139+
<rect key="frame" x="0.0" y="0.0" width="109" height="17"/>
140+
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="LFz-ay-d4l">
141+
<font key="font" metaFont="system"/>
142+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
143+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
144+
</textFieldCell>
145+
</textField>
146+
</subviews>
147+
<constraints>
148+
<constraint firstAttribute="trailing" secondItem="Enk-R3-LoW" secondAttribute="trailing" constant="-34" id="6bB-I6-PLW"/>
149+
<constraint firstItem="Enk-R3-LoW" firstAttribute="leading" secondItem="wX5-ni-A1q" secondAttribute="leading" constant="2" id="bjM-D0-ZXb"/>
150+
<constraint firstItem="Enk-R3-LoW" firstAttribute="centerY" secondItem="wX5-ni-A1q" secondAttribute="centerY" id="p8v-Jc-EyJ"/>
151+
</constraints>
152+
<connections>
153+
<outlet property="textField" destination="Enk-R3-LoW" id="3CV-JU-V6i"/>
154+
</connections>
155+
</tableCellView>
156+
</prototypeCellViews>
157+
</tableColumn>
121158
<tableColumn width="489" minWidth="40" maxWidth="1000" id="JVT-qi-afp">
122159
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Function">
123160
<font key="font" metaFont="smallSystem"/>
@@ -131,8 +168,8 @@
131168
</textFieldCell>
132169
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
133170
<prototypeCellViews>
134-
<tableCellView identifier="Cell2" id="BoE-br-5gO">
135-
<rect key="frame" x="317" y="1" width="489" height="17"/>
171+
<tableCellView identifier="Cell3" id="BoE-br-5gO">
172+
<rect key="frame" x="423" y="1" width="489" height="17"/>
136173
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
137174
<subviews>
138175
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="mMA-YB-bAf">
@@ -174,7 +211,7 @@
174211
<autoresizingMask key="autoresizingMask"/>
175212
</scroller>
176213
<tableHeaderView key="headerView" id="faZ-Wk-Rhw">
177-
<rect key="frame" x="0.0" y="0.0" width="808" height="23"/>
214+
<rect key="frame" x="0.0" y="0.0" width="914" height="23"/>
178215
<autoresizingMask key="autoresizingMask"/>
179216
</tableHeaderView>
180217
</scrollView>
@@ -290,7 +327,7 @@ Gw
290327
<constraint firstItem="NsM-Bv-vw9" firstAttribute="leading" secondItem="Zya-BA-0OX" secondAttribute="trailing" constant="15" id="yVz-YM-eI1"/>
291328
</constraints>
292329
</customView>
293-
<searchField wantsLayer="YES" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bG3-gx-tf3">
330+
<searchField wantsLayer="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bG3-gx-tf3">
294331
<rect key="frame" x="200" y="287" width="400" height="22"/>
295332
<constraints>
296333
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="400" id="3Uu-Zu-ofE"/>
@@ -326,6 +363,7 @@ Gw
326363
<constraint firstItem="ntK-dD-iDV" firstAttribute="centerY" secondItem="rub-4P-XDp" secondAttribute="centerY" id="ZfL-RU-t7l"/>
327364
<constraint firstItem="hRu-er-26V" firstAttribute="centerY" secondItem="Df5-K9-u4q" secondAttribute="centerY" id="ayV-cB-Iap"/>
328365
<constraint firstAttribute="trailing" secondItem="bG3-gx-tf3" secondAttribute="trailing" constant="200" id="bRU-kd-Y4P"/>
366+
<constraint firstItem="qiX-rM-BSu" firstAttribute="top" secondItem="bG3-gx-tf3" secondAttribute="bottom" constant="14" id="cnd-ZH-7NZ"/>
329367
<constraint firstItem="qiX-rM-BSu" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" id="dDY-HK-ZcC"/>
330368
<constraint firstAttribute="bottom" secondItem="qiX-rM-BSu" secondAttribute="bottom" constant="20" id="pT5-B2-WJB"/>
331369
<constraint firstItem="rub-4P-XDp" firstAttribute="leading" secondItem="qiX-rM-BSu" secondAttribute="leading" id="s3D-Bz-lJ5"/>

BuildTimeAnalyzer/CMResultWindowController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ class CMResultWindowController: NSWindowController {
107107
progressIndicator.stopAnimation(self)
108108
statusTextField.stringValue = CMProcessingState.waitingForBuildString
109109
}
110+
progressIndicator.hidden = !shouldIndicate
110111
cancelButton.hidden = true
111112
}
113+
searchField.hidden = !cancelButton.hidden
112114
}
113115

114116
func showInstructions(show: Bool) {

BuildTimeAnalyzerTests/CMCompileMeasureTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class BuildTimeAnalyzerTests: XCTestCase {
2121
let path = "\(folder)\(filename)"
2222
let rawPath = "\(folder)\(fileInfo)"
2323
let code = "some code"
24+
let references = 2
2425

2526
// When
26-
let resultOptional = CMCompileMeasure(time: time, rawPath: rawPath, code: code)
27+
let resultOptional = CMCompileMeasure(time: time, rawPath: rawPath, code: code, references: references)
2728

2829
// Then
2930
XCTAssertNotNil(resultOptional)
@@ -36,5 +37,6 @@ class BuildTimeAnalyzerTests: XCTestCase {
3637
XCTAssertEqual(result.filename, filename)
3738
XCTAssertEqual(result.location, location)
3839
XCTAssertEqual(result.timeString, timeString)
40+
XCTAssertEqual(result.references, references)
3941
}
4042
}

0 commit comments

Comments
 (0)