Skip to content

Commit 6195afc

Browse files
committed
[benchmark] DictionaryOfAnyHashableStrings SO LF
Adjust workload, apply legacyFactor and fix the extra loop of the workload causing the measurable setup overhad.
1 parent c903186 commit 6195afc

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

benchmark/single-source/DictionaryOfAnyHashableStrings.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ public var DictionaryOfAnyHashableStrings = [
2121
name: "DictionaryOfAnyHashableStrings_insert",
2222
runFunction: run_DictionaryOfAnyHashableStrings_insert,
2323
tags: [.abstraction, .runtime, .cpubench],
24-
setUpFunction: {
25-
keys = buildKeys(500)
26-
}
24+
setUpFunction: { keys = buildKeys(50) },
25+
legacyFactor: 14
2726
),
2827
BenchmarkInfo(
2928
name: "DictionaryOfAnyHashableStrings_lookup",
3029
runFunction: run_DictionaryOfAnyHashableStrings_lookup,
3130
tags: [.abstraction, .runtime, .cpubench],
32-
setUpFunction: {
33-
keys = buildKeys(500)
34-
workload = buildWorkload()
35-
}
31+
setUpFunction: { keys = buildKeys(50); workload = buildWorkload() },
32+
legacyFactor: 24
3633
),
3734
]
3835

@@ -65,7 +62,7 @@ func buildWorkload() -> [AnyHashable: Any] {
6562
@inline(never)
6663
public func run_DictionaryOfAnyHashableStrings_insert(_ n: Int) {
6764
precondition(keys.count > 0)
68-
for _ in 0 ... n {
65+
for _ in 1...n {
6966
blackHole(buildWorkload())
7067
}
7168
}
@@ -74,7 +71,7 @@ public func run_DictionaryOfAnyHashableStrings_insert(_ n: Int) {
7471
public func run_DictionaryOfAnyHashableStrings_lookup(_ n: Int) {
7572
precondition(workload.count > 0)
7673
precondition(keys.count > 0)
77-
for _ in 0 ... n {
74+
for _ in 1...n {
7875
for i in 0 ..< keys.count {
7976
let key = keys[i]
8077
CheckResults((workload[key] as! Int) == i)

0 commit comments

Comments
 (0)