Skip to content

Commit e749ac1

Browse files
author
Ferran Pujol Camins
committed
Add performance tests for constructors
1 parent e3ba814 commit e749ac1

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

SwiftGraph.xcodeproj/project.pbxproj

+4-10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
B52ABD39208955BD00FBF10C /* UnionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52ABD37208955B500FBF10C /* UnionTests.swift */; };
4141
B54FDA6E21729EFF00057C51 /* Constructors.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54FDA6D21729EFF00057C51 /* Constructors.swift */; };
4242
B54FDA712172A34D00057C51 /* ConstructorsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54FDA702172A34D00057C51 /* ConstructorsTests.swift */; };
43+
B5D022B1217357480079F17C /* ConstructorsPerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D022B0217357480079F17C /* ConstructorsPerformanceTests.swift */; };
4344
B5D229BC207BF30100151820 /* UniqueElementsGraph.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D229BB207BF30100151820 /* UniqueElementsGraph.swift */; };
4445
B5D229BF207BF3A800151820 /* UniqueElementsGraphTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D229BD207BF36900151820 /* UniqueElementsGraphTests.swift */; };
4546
B5EACB1D2172315E00E527BD /* SwiftGraph.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7985B8FB1E5A4FB800C100E7 /* SwiftGraph.framework */; };
@@ -121,6 +122,7 @@
121122
B52ABD37208955B500FBF10C /* UnionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnionTests.swift; sourceTree = "<group>"; };
122123
B54FDA6D21729EFF00057C51 /* Constructors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Constructors.swift; path = ../Sources/SwiftGraph/Constructors.swift; sourceTree = "<group>"; };
123124
B54FDA702172A34D00057C51 /* ConstructorsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstructorsTests.swift; sourceTree = "<group>"; };
125+
B5D022B0217357480079F17C /* ConstructorsPerformanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstructorsPerformanceTests.swift; sourceTree = "<group>"; };
124126
B5D229BB207BF30100151820 /* UniqueElementsGraph.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UniqueElementsGraph.swift; path = Sources/SwiftGraph/UniqueElementsGraph.swift; sourceTree = SOURCE_ROOT; };
125127
B5D229BD207BF36900151820 /* UniqueElementsGraphTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UniqueElementsGraphTests.swift; sourceTree = "<group>"; };
126128
B5DD6DA42171EEE1007EFF44 /* SearchPerformanceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchPerformanceTests.swift; sourceTree = "<group>"; };
@@ -300,18 +302,11 @@
300302
name = Operations;
301303
sourceTree = "<group>";
302304
};
303-
B5DD6DA62171EF7E007EFF44 /* TestUtils */ = {
304-
isa = PBXGroup;
305-
children = (
306-
B5DD6DA72171F0DA007EFF44 /* GraphGeneration.swift */,
307-
);
308-
path = TestUtils;
309-
sourceTree = "<group>";
310-
};
311305
B5EACB09217230ED00E527BD /* SwiftGraphPerformanceTests */ = {
312306
isa = PBXGroup;
313307
children = (
314308
B5DD6DA42171EEE1007EFF44 /* SearchPerformanceTests.swift */,
309+
B5D022B0217357480079F17C /* ConstructorsPerformanceTests.swift */,
315310
);
316311
name = SwiftGraphPerformanceTests;
317312
path = Tests/SwiftGraphPerformanceTests;
@@ -540,9 +535,8 @@
540535
isa = PBXSourcesBuildPhase;
541536
buildActionMask = 2147483647;
542537
files = (
543-
B5EACB2B217233E300E527BD /* DFS.swift in Sources */,
544-
B5EACB2A217233DB00E527BD /* GraphGeneration.swift in Sources */,
545538
B5EACB292172336900E527BD /* SearchPerformanceTests.swift in Sources */,
539+
B5D022B1217357480079F17C /* ConstructorsPerformanceTests.swift in Sources */,
546540
);
547541
runOnlyForDeploymentPostprocessing = 0;
548542
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// ConstructorsPerformanceTests.swift
3+
// SwiftGraphTests
4+
//
5+
// Copyright (c) 2018 Ferran Pujol Camins
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
import XCTest
20+
@testable import SwiftGraph
21+
22+
class ConstructorsPerformanceTests: XCTestCase {
23+
func testStarGraphConstructor() {
24+
self.measure {
25+
_ = StarGraph.build(withCenter: 0, andLeafs: Array(1...999999))
26+
}
27+
}
28+
29+
func testCompleteGraphConstructor() {
30+
self.measure {
31+
_ = CompleteGraph.build(withVertices: Array(0...1999))
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)