Skip to content

Commit 8672455

Browse files
committed
[benchmark] Add large unicode String<->Data benchmark.
Add a larger unicody workload, beyond the medium-sized ASCII that currently exists.
1 parent c4ff5a1 commit 8672455

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

benchmark/single-source/DataBenchmarks.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ public let DataBenchmarks = [
164164
BenchmarkInfo(name: "DataToStringMedium",
165165
runFunction: { string($0*200, from: mediumData) }, tags: d,
166166
legacyFactor: 50),
167+
BenchmarkInfo(name: "DataToStringLargeUnicode",
168+
runFunction: { string($0*200, from: largeUnicodeData) }, tags: d,
169+
legacyFactor: 50),
167170

168171
BenchmarkInfo(name: "StringToDataEmpty",
169172
runFunction: { data($0*200, from: emptyString) }, tags: d,
@@ -174,6 +177,9 @@ public let DataBenchmarks = [
174177
BenchmarkInfo(name: "StringToDataMedium",
175178
runFunction: { data($0*200, from: mediumString) }, tags: d,
176179
legacyFactor: 50),
180+
BenchmarkInfo(name: "StringToDataLargeUnicode",
181+
runFunction: { data($0*200, from: largeUnicodeString) }, tags: d,
182+
legacyFactor: 50),
177183

178184
BenchmarkInfo(name: "Data.hash.Empty",
179185
runFunction: { hash($0*10_000, data: Data()) }, tags: d),
@@ -186,9 +192,12 @@ public let DataBenchmarks = [
186192
let emptyString = ""
187193
let smallString = "\r\n"
188194
let mediumString = "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
195+
let largeUnicodeString =
196+
"Swiftに大幅な改良が施され、𓀀𓀁𓀂𓀃, 🇺🇸🇨🇦🇲🇽" + mediumString
189197
let emptyData = Data()
190198
let smallData = Data(smallString.utf8)
191199
let mediumData = Data(mediumString.utf8)
200+
let largeUnicodeData = Data(largeUnicodeString.utf8)
192201

193202
let small = sampleData(.small)
194203
let medium = sampleData(.medium)

0 commit comments

Comments
 (0)