Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorted collections #65

Merged
merged 15 commits into from
Nov 22, 2021
Merged
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
87 changes: 87 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/SortedCollections.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SortedCollections"
BuildableName = "SortedCollections"
BlueprintName = "SortedCollections"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
enableASanStackUseAfterReturn = "YES"
codeCoverageEnabled = "YES">
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SortedCollectionsTests"
BuildableName = "SortedCollectionsTests"
BlueprintName = "SortedCollectionsTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SortedCollections"
BuildableName = "SortedCollections"
BlueprintName = "SortedCollections"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "OrderedCollections"
BuildableName = "OrderedCollections"
BlueprintName = "OrderedCollections"
BlueprintIdentifier = "DequeTests"
BuildableName = "DequeTests"
BlueprintName = "DequeTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -56,9 +56,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "swift-collections-benchmark"
BuildableName = "swift-collections-benchmark"
BlueprintName = "swift-collections-benchmark"
BlueprintIdentifier = "CollectionsTestSupport"
BuildableName = "CollectionsTestSupport"
BlueprintName = "CollectionsTestSupport"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -70,9 +70,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CollectionsTestSupport"
BuildableName = "CollectionsTestSupport"
BlueprintName = "CollectionsTestSupport"
BlueprintIdentifier = "swift-collections-benchmark"
BuildableName = "swift-collections-benchmark"
BlueprintName = "swift-collections-benchmark"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -106,29 +106,29 @@
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DequeTests"
BuildableName = "DequeTests"
BlueprintName = "DequeTests"
BlueprintIdentifier = "OrderedCollections"
BuildableName = "OrderedCollections"
BlueprintName = "OrderedCollections"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CollectionsTestSupportTests"
BuildableName = "CollectionsTestSupportTests"
BlueprintName = "CollectionsTestSupportTests"
BlueprintIdentifier = "PriorityQueueModule"
BuildableName = "PriorityQueueModule"
BlueprintName = "PriorityQueueModule"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -140,9 +140,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PriorityQueueModule"
BuildableName = "PriorityQueueModule"
BlueprintName = "PriorityQueueModule"
BlueprintIdentifier = "SortedCollections"
BuildableName = "SortedCollections"
BlueprintName = "SortedCollections"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -194,6 +194,16 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SortedCollectionsTests"
BuildableName = "SortedCollectionsTests"
BlueprintName = "SortedCollectionsTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SortedCollectionsTests"
BuildableName = "SortedCollectionsTests"
BlueprintName = "SortedCollectionsTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
buildConfiguration = "Release"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -80,6 +90,12 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "run"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
43 changes: 43 additions & 0 deletions Benchmarks/Benchmarks/CppBenchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@ internal class CppPriorityQueue {
}
}

internal class CppMap {
var ptr: UnsafeMutableRawPointer?

init(_ input: [Int]) {
self.ptr = input.withUnsafeBufferPointer { buffer in
cpp_map_create(buffer.baseAddress, buffer.count)
}
}

deinit {
destroy()
}

func destroy() {
if let ptr = ptr {
cpp_map_destroy(ptr)
}
ptr = nil
}
}

extension Benchmark {
public mutating func addCppBenchmarks() {
Expand Down Expand Up @@ -706,5 +726,28 @@ extension Benchmark {
pq.destroy()
}
}

//--------------------------------------------------------------------------

self.addSimple(
title: "std::map<intptr_t, intptr_t> insert",
input: [Int].self
) { input in
input.withUnsafeBufferPointer { buffer in
cpp_map_insert_integers(buffer.baseAddress, buffer.count)
}
}

self.add(
title: "std::map<intptr_t, intptr_t> successful find",
input: ([Int], [Int]).self
) { input, lookups in
let map = CppMap(input)
return { timer in
lookups.withUnsafeBufferPointer { buffer in
cpp_map_lookups(map.ptr, buffer.baseAddress, buffer.count)
}
}
}
}
}
Loading