Skip to content

Commit b472a6f

Browse files
authored
Merge pull request #65 from vihanb/sorted-collections
Sorted collections
2 parents cc69069 + 478d3cc commit b472a6f

File tree

75 files changed

+11753
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+11753
-32
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1250"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "SortedCollections"
18+
BuildableName = "SortedCollections"
19+
BlueprintName = "SortedCollections"
20+
ReferencedContainer = "container:">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
enableASanStackUseAfterReturn = "YES"
31+
codeCoverageEnabled = "YES">
32+
<AdditionalOptions>
33+
<AdditionalOption
34+
key = "NSZombieEnabled"
35+
value = "YES"
36+
isEnabled = "YES">
37+
</AdditionalOption>
38+
</AdditionalOptions>
39+
<Testables>
40+
<TestableReference
41+
skipped = "NO">
42+
<BuildableReference
43+
BuildableIdentifier = "primary"
44+
BlueprintIdentifier = "SortedCollectionsTests"
45+
BuildableName = "SortedCollectionsTests"
46+
BlueprintName = "SortedCollectionsTests"
47+
ReferencedContainer = "container:">
48+
</BuildableReference>
49+
</TestableReference>
50+
</Testables>
51+
</TestAction>
52+
<LaunchAction
53+
buildConfiguration = "Debug"
54+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
55+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
56+
enableASanStackUseAfterReturn = "YES"
57+
launchStyle = "0"
58+
useCustomWorkingDirectory = "NO"
59+
ignoresPersistentStateOnLaunch = "NO"
60+
debugDocumentVersioning = "YES"
61+
debugServiceExtension = "internal"
62+
allowLocationSimulation = "YES">
63+
</LaunchAction>
64+
<ProfileAction
65+
buildConfiguration = "Release"
66+
shouldUseLaunchSchemeArgsEnv = "YES"
67+
savedToolIdentifier = ""
68+
useCustomWorkingDirectory = "NO"
69+
debugDocumentVersioning = "YES">
70+
<MacroExpansion>
71+
<BuildableReference
72+
BuildableIdentifier = "primary"
73+
BlueprintIdentifier = "SortedCollections"
74+
BuildableName = "SortedCollections"
75+
BlueprintName = "SortedCollections"
76+
ReferencedContainer = "container:">
77+
</BuildableReference>
78+
</MacroExpansion>
79+
</ProfileAction>
80+
<AnalyzeAction
81+
buildConfiguration = "Debug">
82+
</AnalyzeAction>
83+
<ArchiveAction
84+
buildConfiguration = "Release"
85+
revealArchiveInOrganizer = "YES">
86+
</ArchiveAction>
87+
</Scheme>

.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-Package.xcscheme

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
<BuildActionEntry
3838
buildForTesting = "YES"
3939
buildForRunning = "YES"
40-
buildForProfiling = "YES"
41-
buildForArchiving = "YES"
40+
buildForProfiling = "NO"
41+
buildForArchiving = "NO"
4242
buildForAnalyzing = "YES">
4343
<BuildableReference
4444
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "OrderedCollections"
46-
BuildableName = "OrderedCollections"
47-
BlueprintName = "OrderedCollections"
45+
BlueprintIdentifier = "DequeTests"
46+
BuildableName = "DequeTests"
47+
BlueprintName = "DequeTests"
4848
ReferencedContainer = "container:">
4949
</BuildableReference>
5050
</BuildActionEntry>
@@ -56,9 +56,9 @@
5656
buildForAnalyzing = "YES">
5757
<BuildableReference
5858
BuildableIdentifier = "primary"
59-
BlueprintIdentifier = "swift-collections-benchmark"
60-
BuildableName = "swift-collections-benchmark"
61-
BlueprintName = "swift-collections-benchmark"
59+
BlueprintIdentifier = "CollectionsTestSupport"
60+
BuildableName = "CollectionsTestSupport"
61+
BlueprintName = "CollectionsTestSupport"
6262
ReferencedContainer = "container:">
6363
</BuildableReference>
6464
</BuildActionEntry>
@@ -70,9 +70,9 @@
7070
buildForAnalyzing = "YES">
7171
<BuildableReference
7272
BuildableIdentifier = "primary"
73-
BlueprintIdentifier = "CollectionsTestSupport"
74-
BuildableName = "CollectionsTestSupport"
75-
BlueprintName = "CollectionsTestSupport"
73+
BlueprintIdentifier = "swift-collections-benchmark"
74+
BuildableName = "swift-collections-benchmark"
75+
BlueprintName = "swift-collections-benchmark"
7676
ReferencedContainer = "container:">
7777
</BuildableReference>
7878
</BuildActionEntry>
@@ -106,29 +106,29 @@
106106
</BuildActionEntry>
107107
<BuildActionEntry
108108
buildForTesting = "YES"
109-
buildForRunning = "NO"
110-
buildForProfiling = "NO"
111-
buildForArchiving = "NO"
112-
buildForAnalyzing = "NO">
109+
buildForRunning = "YES"
110+
buildForProfiling = "YES"
111+
buildForArchiving = "YES"
112+
buildForAnalyzing = "YES">
113113
<BuildableReference
114114
BuildableIdentifier = "primary"
115-
BlueprintIdentifier = "DequeTests"
116-
BuildableName = "DequeTests"
117-
BlueprintName = "DequeTests"
115+
BlueprintIdentifier = "OrderedCollections"
116+
BuildableName = "OrderedCollections"
117+
BlueprintName = "OrderedCollections"
118118
ReferencedContainer = "container:">
119119
</BuildableReference>
120120
</BuildActionEntry>
121121
<BuildActionEntry
122122
buildForTesting = "YES"
123-
buildForRunning = "NO"
124-
buildForProfiling = "NO"
125-
buildForArchiving = "NO"
126-
buildForAnalyzing = "NO">
123+
buildForRunning = "YES"
124+
buildForProfiling = "YES"
125+
buildForArchiving = "YES"
126+
buildForAnalyzing = "YES">
127127
<BuildableReference
128128
BuildableIdentifier = "primary"
129-
BlueprintIdentifier = "CollectionsTestSupportTests"
130-
BuildableName = "CollectionsTestSupportTests"
131-
BlueprintName = "CollectionsTestSupportTests"
129+
BlueprintIdentifier = "PriorityQueueModule"
130+
BuildableName = "PriorityQueueModule"
131+
BlueprintName = "PriorityQueueModule"
132132
ReferencedContainer = "container:">
133133
</BuildableReference>
134134
</BuildActionEntry>
@@ -140,9 +140,9 @@
140140
buildForAnalyzing = "YES">
141141
<BuildableReference
142142
BuildableIdentifier = "primary"
143-
BlueprintIdentifier = "PriorityQueueModule"
144-
BuildableName = "PriorityQueueModule"
145-
BlueprintName = "PriorityQueueModule"
143+
BlueprintIdentifier = "SortedCollections"
144+
BuildableName = "SortedCollections"
145+
BlueprintName = "SortedCollections"
146146
ReferencedContainer = "container:">
147147
</BuildableReference>
148148
</BuildActionEntry>
@@ -194,6 +194,16 @@
194194
ReferencedContainer = "container:">
195195
</BuildableReference>
196196
</TestableReference>
197+
<TestableReference
198+
skipped = "NO">
199+
<BuildableReference
200+
BuildableIdentifier = "primary"
201+
BlueprintIdentifier = "SortedCollectionsTests"
202+
BuildableName = "SortedCollectionsTests"
203+
BlueprintName = "SortedCollectionsTests"
204+
ReferencedContainer = "container:">
205+
</BuildableReference>
206+
</TestableReference>
197207
</Testables>
198208
</TestAction>
199209
<LaunchAction

.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-benchmark.xcscheme

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,22 @@
5858
ReferencedContainer = "container:">
5959
</BuildableReference>
6060
</TestableReference>
61+
<TestableReference
62+
skipped = "NO">
63+
<BuildableReference
64+
BuildableIdentifier = "primary"
65+
BlueprintIdentifier = "SortedCollectionsTests"
66+
BuildableName = "SortedCollectionsTests"
67+
BlueprintName = "SortedCollectionsTests"
68+
ReferencedContainer = "container:">
69+
</BuildableReference>
70+
</TestableReference>
6171
</Testables>
6272
</TestAction>
6373
<LaunchAction
64-
buildConfiguration = "Debug"
65-
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
66-
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
74+
buildConfiguration = "Release"
75+
selectedDebuggerIdentifier = ""
76+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
6777
launchStyle = "0"
6878
useCustomWorkingDirectory = "NO"
6979
ignoresPersistentStateOnLaunch = "NO"
@@ -80,6 +90,12 @@
8090
ReferencedContainer = "container:">
8191
</BuildableReference>
8292
</BuildableProductRunnable>
93+
<CommandLineArguments>
94+
<CommandLineArgument
95+
argument = "run"
96+
isEnabled = "YES">
97+
</CommandLineArgument>
98+
</CommandLineArguments>
8399
</LaunchAction>
84100
<ProfileAction
85101
buildConfiguration = "Release"

Benchmarks/Benchmarks/CppBenchmarks.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,26 @@ internal class CppPriorityQueue {
139139
}
140140
}
141141

142+
internal class CppMap {
143+
var ptr: UnsafeMutableRawPointer?
144+
145+
init(_ input: [Int]) {
146+
self.ptr = input.withUnsafeBufferPointer { buffer in
147+
cpp_map_create(buffer.baseAddress, buffer.count)
148+
}
149+
}
150+
151+
deinit {
152+
destroy()
153+
}
154+
155+
func destroy() {
156+
if let ptr = ptr {
157+
cpp_map_destroy(ptr)
158+
}
159+
ptr = nil
160+
}
161+
}
142162

143163
extension Benchmark {
144164
public mutating func addCppBenchmarks() {
@@ -706,5 +726,28 @@ extension Benchmark {
706726
pq.destroy()
707727
}
708728
}
729+
730+
//--------------------------------------------------------------------------
731+
732+
self.addSimple(
733+
title: "std::map<intptr_t, intptr_t> insert",
734+
input: [Int].self
735+
) { input in
736+
input.withUnsafeBufferPointer { buffer in
737+
cpp_map_insert_integers(buffer.baseAddress, buffer.count)
738+
}
739+
}
740+
741+
self.add(
742+
title: "std::map<intptr_t, intptr_t> successful find",
743+
input: ([Int], [Int]).self
744+
) { input, lookups in
745+
let map = CppMap(input)
746+
return { timer in
747+
lookups.withUnsafeBufferPointer { buffer in
748+
cpp_map_lookups(map.ptr, buffer.baseAddress, buffer.count)
749+
}
750+
}
751+
}
709752
}
710753
}

0 commit comments

Comments
 (0)