Content-Length: 679702 | pFad | http://github.com/davecom/SwiftGraph/commit/6fae5092e240bdbacecd49720134ec7fb93feaf6

0A Add performance tests for bfs and dfs · davecom/SwiftGraph@6fae509 · GitHub
Skip to content

Commit 6fae509

Browse files
ferranpujolcaminsFerran Pujol Camins
authored and
Ferran Pujol Camins
committed
Add performance tests for bfs and dfs
1 parent 2fa5a27 commit 6fae509

File tree

4 files changed

+124
-22
lines changed

4 files changed

+124
-22
lines changed

Diff for: SwiftGraph.xcodeproj/xcshareddata/xcbaselines/B5EACB0A2172315E00E527BD.xcbaseline/94D648AC-76B2-4B8F-A1FF-3A34FAC1AF9B.plist

+83
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,89 @@
107107
</dict>
108108
</dict>
109109
</dict>
110+
<key>SearchPerformanceTests</key>
111+
<dict>
112+
<key>testBfsInCompleteGraph()</key>
113+
<dict>
114+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
115+
<dict>
116+
<key>baselineAverage</key>
117+
<real>0.83567</real>
118+
<key>baselineIntegrationDisplayName</key>
119+
<string>Local Baseline</string>
120+
</dict>
121+
</dict>
122+
<key>testBfsInPath()</key>
123+
<dict>
124+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
125+
<dict>
126+
<key>baselineAverage</key>
127+
<real>0.108</real>
128+
<key>baselineIntegrationDisplayName</key>
129+
<string>Local Baseline</string>
130+
</dict>
131+
</dict>
132+
<key>testBfsInStarGraph()</key>
133+
<dict>
134+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
135+
<dict>
136+
<key>baselineAverage</key>
137+
<real>1.0987</real>
138+
<key>baselineIntegrationDisplayName</key>
139+
<string>Local Baseline</string>
140+
</dict>
141+
</dict>
142+
<key>testBfsInStarGraphByIndex()</key>
143+
<dict>
144+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
145+
<dict>
146+
<key>baselineAverage</key>
147+
<real>1.0866</real>
148+
<key>baselineIntegrationDisplayName</key>
149+
<string>Local Baseline</string>
150+
</dict>
151+
</dict>
152+
<key>testDfsInCompleteGraph()</key>
153+
<dict>
154+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
155+
<dict>
156+
<key>baselineAverage</key>
157+
<real>0.974</real>
158+
<key>baselineIntegrationDisplayName</key>
159+
<string>Local Baseline</string>
160+
</dict>
161+
</dict>
162+
<key>testDfsInPath()</key>
163+
<dict>
164+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
165+
<dict>
166+
<key>baselineAverage</key>
167+
<real>0.11</real>
168+
<key>baselineIntegrationDisplayName</key>
169+
<string>Local Baseline</string>
170+
</dict>
171+
</dict>
172+
<key>testDfsInPathByIndex()</key>
173+
<dict>
174+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
175+
<dict>
176+
<key>baselineAverage</key>
177+
<real>0.0955</real>
178+
<key>baselineIntegrationDisplayName</key>
179+
<string>Local Baseline</string>
180+
</dict>
181+
</dict>
182+
<key>testDfsInStarGraph()</key>
183+
<dict>
184+
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
185+
<dict>
186+
<key>baselineAverage</key>
187+
<real>0.113</real>
188+
<key>baselineIntegrationDisplayName</key>
189+
<string>Local Baseline</string>
190+
</dict>
191+
</dict>
192+
</dict>
110193
</dict>
111194
</dict>
112195
</plist>

Diff for: Tests/SwiftGraphPerformanceTests/ConstructorsPerformanceTests.swift

-11
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,4 @@ class ConstructorsPerformanceTests: XCTestCase {
7474
_ = CompleteGraph.build(withVertices: Array(0...1999))
7575
}
7676
}
77-
78-
static var allTests = [
79-
("testPathUnweightedGraphConstructor", testPathUnweightedGraphConstructor),
80-
("testCycleUnweightedGraphConstructor", testCycleUnweightedGraphConstructor),
81-
("testPathUniqueElementsGraphConstructor", testPathUniqueElementsGraphConstructor),
82-
("testPathUniqueElementsGraphHashableConstructor", testPathUniqueElementsGraphHashableConstructor),
83-
("testCycleUniqueElementsGraphConstructor", testCycleUniqueElementsGraphConstructor),
84-
("testCycleUniqueElementsHashableConstructor", testCycleUniqueElementsHashableConstructor),
85-
("testStarGraphConstructor", testStarGraphConstructor),
86-
("testCompleteGraphConstructor", testCompleteGraphConstructor),
87-
]
8877
}

Diff for: Tests/SwiftGraphPerformanceTests/SearchPerformanceTests.swift

+36-11
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,55 @@ import XCTest
2020
@testable import SwiftGraph
2121

2222
class SearchPerformanceTests: XCTestCase {
23+
let starGraph = StarGraph.build(withCenter: 0, andLeafs: Array(1...99999))
24+
let pathGraph = UnweightedGraph(withPath: Array(0...99999))
25+
let completeGraph = CompleteGraph.build(withVertices: Array(0...2499))
26+
2327
func testDfsInStarGraph() {
24-
let g = StarGraph.build(withCenter: 0, andLeafs: Array(1...999999))
2528
self.measure {
26-
_ = g.dfs(from: 0, goalTest: { _ in false })
29+
_ = starGraph.dfs(from: 0, goalTest: { _ in false })
30+
}
31+
}
32+
33+
func testBfsInStarGraph() {
34+
self.measure {
35+
_ = starGraph.bfs(from: 0, goalTest: { _ in false })
36+
}
37+
}
38+
39+
func testBfsInStarGraphByIndex() {
40+
self.measure {
41+
_ = starGraph.bfs(fromIndex: 0, toIndex: -1)
2742
}
2843
}
2944

3045
func testDfsInPath() {
31-
let g = UnweightedGraph(withPath: Array(0...999999))
3246
self.measure {
33-
_ = g.dfs(from: 0, goalTest: { _ in false })
47+
_ = pathGraph.dfs(from: 0, goalTest: { _ in false })
48+
}
49+
}
50+
51+
func testDfsInPathByIndex() {
52+
self.measure {
53+
_ = pathGraph.dfs(fromIndex: 0, toIndex: -1)
54+
}
55+
}
56+
57+
func testBfsInPath() {
58+
self.measure {
59+
_ = pathGraph.bfs(from: 0, goalTest: { _ in false })
3460
}
3561
}
3662

3763
func testDfsInCompleteGraph() {
38-
let g = CompleteGraph.build(withVertices: Array(0...2999))
3964
self.measure {
40-
_ = g.dfs(from: 0, goalTest: { _ in false })
65+
_ = completeGraph.dfs(from: 0, goalTest: { _ in false })
4166
}
4267
}
4368

44-
static var allTests = [
45-
("testDfsInStarGraph", testDfsInStarGraph),
46-
("testDfsInPath", testDfsInPath),
47-
("testDfsInCompleteGraph", testDfsInCompleteGraph)
48-
]
69+
func testBfsInCompleteGraph() {
70+
self.measure {
71+
_ = completeGraph.bfs(from: 0, goalTest: { _ in false })
72+
}
73+
}
4974
}

Diff for: Tests/SwiftGraphPerformanceTests/XCTestManifests.swift

+5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ extension ConstructorsPerformanceTests {
1515

1616
extension SearchPerformanceTests {
1717
static let __allTests = [
18+
("testBfsInCompleteGraph", testBfsInCompleteGraph),
19+
("testBfsInPath", testBfsInPath),
20+
("testBfsInStarGraph", testBfsInStarGraph),
21+
("testBfsInStarGraphByIndex", testBfsInStarGraphByIndex),
1822
("testDfsInCompleteGraph", testDfsInCompleteGraph),
1923
("testDfsInPath", testDfsInPath),
24+
("testDfsInPathByIndex", testDfsInPathByIndex),
2025
("testDfsInStarGraph", testDfsInStarGraph),
2126
]
2227
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/davecom/SwiftGraph/commit/6fae5092e240bdbacecd49720134ec7fb93feaf6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy