Skip to content

Commit aa39122

Browse files
[benchmark] Make small int parsing take >20µs
1 parent 414d860 commit aa39122

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

benchmark/single-source/IntegerParsing.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,45 +77,49 @@ private let largeUncommonRadixStrings: [String]
7777
@inline(never)
7878
public func run_ParseIntFromSmallDecimal(N: Int) {
7979
var result = 0
80-
for _ in 0..<N {
80+
let count = N*10
81+
for _ in 0..<count {
8182
for string in smallDecimalStrings {
8283
result &+= Int(string, radix: 10)!
8384
}
8485
}
85-
CheckResults(result == smallValuesSum &* N)
86+
CheckResults(result == smallValuesSum &* count)
8687
}
8788

8889
@inline(never)
8990
public func run_ParseIntFromSmallBinary(N: Int) {
9091
var result = 0
91-
for _ in 0..<N {
92+
let count = N*10
93+
for _ in 0..<count {
9294
for string in smallBinaryStrings {
9395
result &+= Int(string, radix: 2)!
9496
}
9597
}
96-
CheckResults(result == smallValuesSum &* N)
98+
CheckResults(result == smallValuesSum &* count)
9799
}
98100

99101
@inline(never)
100102
public func run_ParseIntFromSmallHex(N: Int) {
101103
var result = 0
102-
for _ in 0..<N {
104+
let count = N*10
105+
for _ in 0..<count {
103106
for string in smallHexStrings {
104107
result &+= Int(string, radix: 16)!
105108
}
106109
}
107-
CheckResults(result == smallValuesSum &* N)
110+
CheckResults(result == smallValuesSum &* count)
108111
}
109112

110113
@inline(never)
111114
public func run_ParseIntFromSmallUncommonRadix(N: Int) {
112115
var result = 0
113-
for _ in 0..<N {
116+
let count = N*10
117+
for _ in 0..<count {
114118
for string in smallUncommonRadixStrings {
115119
result &+= Int(string, radix: uncommonRadix)!
116120
}
117121
}
118-
CheckResults(result == smallValuesSum &* N)
122+
CheckResults(result == smallValuesSum &* count)
119123
}
120124

121125
@inline(never)

0 commit comments

Comments
 (0)