Skip to content

Commit 7c8beb7

Browse files
committed
[benchmark] StringBuilder Legacy Factor
1 parent 8051905 commit 7c8beb7

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

benchmark/single-source/StringBuilder.swift

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,33 @@ public let StringBuilder = [
2828
BenchmarkInfo(
2929
name: "StringUTF16Builder",
3030
runFunction: run_StringUTF16Builder,
31-
tags: [.validation, .api, .String]),
31+
tags: [.validation, .api, .String],
32+
legacyFactor: 10),
3233
BenchmarkInfo(
3334
name: "StringUTF16SubstringBuilder",
3435
runFunction: run_StringUTF16SubstringBuilder,
35-
tags: [.validation, .api, .String]),
36+
tags: [.validation, .api, .String],
37+
legacyFactor: 10),
3638
BenchmarkInfo(
3739
name: "StringBuilderLong",
3840
runFunction: run_StringBuilderLong,
39-
tags: [.validation, .api, .String]),
41+
tags: [.validation, .api, .String],
42+
legacyFactor: 10),
4043
BenchmarkInfo(
4144
name: "StringBuilderWithLongSubstring",
4245
runFunction: run_StringBuilderWithLongSubstring,
43-
tags: [.validation, .api, .String]),
46+
tags: [.validation, .api, .String],
47+
legacyFactor: 10),
4448
BenchmarkInfo(
4549
name: "StringWordBuilder",
4650
runFunction: run_StringWordBuilder,
47-
tags: [.validation, .api, .String]),
51+
tags: [.validation, .api, .String],
52+
legacyFactor: 10),
4853
BenchmarkInfo(
4954
name: "StringWordBuilderReservingCapacity",
5055
runFunction: run_StringWordBuilderReservingCapacity,
51-
tags: [.validation, .api, .String]),
56+
tags: [.validation, .api, .String],
57+
legacyFactor: 10),
5258
]
5359

5460
@inline(never)
@@ -110,14 +116,14 @@ func buildStringFromSmallSubstrings(_ i: String) -> String {
110116

111117
@inline(never)
112118
public func run_StringUTF16Builder(_ N: Int) {
113-
for _ in 1...5000*N {
119+
for _ in 1...500*N {
114120
blackHole(buildStringUTF16("a"))
115121
}
116122
}
117123

118124
@inline(never)
119125
public func run_StringUTF16SubstringBuilder(_ N: Int) {
120-
for _ in 1...5000*N {
126+
for _ in 1...500*N {
121127
blackHole(buildStringFromSmallSubstrings("a"))
122128
}
123129
}
@@ -153,14 +159,14 @@ func buildStringWithLongSubstring(_ i: String) -> String {
153159

154160
@inline(never)
155161
public func run_StringBuilderLong(_ N: Int) {
156-
for _ in 1...5000*N {
162+
for _ in 1...500*N {
157163
blackHole(buildStringLong("👻"))
158164
}
159165
}
160166

161167
@inline(never)
162168
public func run_StringBuilderWithLongSubstring(_ N: Int) {
163-
for _ in 1...5000*N {
169+
for _ in 1...500*N {
164170
blackHole(buildStringWithLongSubstring("👻"))
165171
}
166172
}
@@ -184,13 +190,16 @@ func buildString(
184190

185191
@inline(never)
186192
public func run_StringWordBuilder(_ N: Int) {
187-
blackHole(buildString(
188-
word: "bumfuzzle", count: 50_000 * N, reservingCapacity: false))
193+
for _ in 1...N {
194+
blackHole(buildString(
195+
word: "bumfuzzle", count: 5_000, reservingCapacity: false))
196+
}
189197
}
190198

191199
@inline(never)
192200
public func run_StringWordBuilderReservingCapacity(_ N: Int) {
193-
blackHole(buildString(
194-
word: "bumfuzzle", count: 50_000 * N, reservingCapacity: true))
201+
for _ in 1...N {
202+
blackHole(buildString(
203+
word: "bumfuzzle", count: 5_000, reservingCapacity: true))
204+
}
195205
}
196-

0 commit comments

Comments
 (0)