mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
[Capsule] Add [COW] subscript, remove existing benchmark
This commit is contained in:
1 parent
60f0b6d109
commit
92d07b3910
3 files changed
+57
No files matched your search
@@ -194,6 +194,25 @@ extension Benchmark {
|
||||
}
|
||||
}
|
||||
|
||||
self.add(
|
||||
title: "Dictionary<Int, Int> [COW] subscript, remove existing",
|
||||
input: ([Int], [Int]).self
|
||||
) { input, lookups in
|
||||
return { timer in
|
||||
let d = Dictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) })
|
||||
timer.measure {
|
||||
for i in lookups {
|
||||
var e = d
|
||||
e[i] = nil
|
||||
precondition(e.count == input.count - 1)
|
||||
blackHole(e)
|
||||
}
|
||||
}
|
||||
precondition(d.count == input.count)
|
||||
blackHole(d)
|
||||
}
|
||||
}
|
||||
|
||||
self.add(
|
||||
title: "Dictionary<Int, Int> subscript, remove missing",
|
||||
input: ([Int], [Int]).self
|
||||
|
||||
@@ -226,6 +226,25 @@ extension Benchmark {
|
||||
}
|
||||
}
|
||||
|
||||
self.add(
|
||||
title: "OrderedDictionary<Int, Int> [COW] subscript, remove existing",
|
||||
input: ([Int], [Int]).self
|
||||
) { input, lookups in
|
||||
return { timer in
|
||||
let d = OrderedDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) })
|
||||
timer.measure {
|
||||
for i in lookups {
|
||||
var e = d
|
||||
e[i] = nil
|
||||
precondition(e.count == input.count - 1)
|
||||
blackHole(e)
|
||||
}
|
||||
}
|
||||
precondition(d.count == input.count)
|
||||
blackHole(d)
|
||||
}
|
||||
}
|
||||
|
||||
self.add(
|
||||
title: "OrderedDictionary<Int, Int> subscript, remove missing",
|
||||
input: ([Int], [Int]).self
|
||||
|
||||
@@ -182,6 +182,25 @@ extension Benchmark {
|
||||
}
|
||||
}
|
||||
|
||||
self.add(
|
||||
title: "PersistentDictionary<Int, Int> [COW] subscript, remove existing",
|
||||
input: ([Int], [Int]).self
|
||||
) { input, lookups in
|
||||
return { timer in
|
||||
let d = PersistentDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) })
|
||||
timer.measure {
|
||||
for i in lookups {
|
||||
var e = d
|
||||
e[i] = nil
|
||||
precondition(e.count == input.count - 1)
|
||||
blackHole(e)
|
||||
}
|
||||
}
|
||||
precondition(d.count == input.count)
|
||||
blackHole(d)
|
||||
}
|
||||
}
|
||||
|
||||
self.add(
|
||||
title: "PersistentDictionary<Int, Int> subscript, remove missing",
|
||||
input: ([Int], [Int]).self
|
||||
|
||||
Reference in new issue
Block a user