@@ -168,17 +168,30 @@ public let DataBenchmarks = [
168
168
runFunction: { string ( $0* 200 , from: largeUnicodeData) } , tags: d,
169
169
legacyFactor: 50 ) ,
170
170
171
- BenchmarkInfo ( name: " StringToDataEmpty " ,
172
- runFunction: { data ( $0* 200 , from: emptyString) } , tags: d,
171
+ BenchmarkInfo ( name: " StringToDataFromUTF8ViewEmpty " ,
172
+ runFunction: { dataFromUTF8View ( $0* 200 , from: emptyString) } , tags: d,
173
173
legacyFactor: 50 ) ,
174
- BenchmarkInfo ( name: " StringToDataSmall " ,
175
- runFunction: { data ( $0* 200 , from: smallString) } , tags: d,
174
+ BenchmarkInfo ( name: " StringToDataFromUTF8ViewSmall " ,
175
+ runFunction: { dataFromUTF8View ( $0* 200 , from: smallString) } , tags: d,
176
176
legacyFactor: 50 ) ,
177
- BenchmarkInfo ( name: " StringToDataMedium " ,
178
- runFunction: { data ( $0* 200 , from: mediumString) } , tags: d,
177
+ BenchmarkInfo ( name: " StringToDataFromUTF8ViewMedium " ,
178
+ runFunction: { dataFromUTF8View ( $0* 200 , from: mediumString) } , tags: d,
179
179
legacyFactor: 50 ) ,
180
- BenchmarkInfo ( name: " StringToDataLargeUnicode " ,
181
- runFunction: { data ( $0* 200 , from: largeUnicodeString) } , tags: d,
180
+ BenchmarkInfo ( name: " StringToDataFromUTF8ViewLargeUnicode " ,
181
+ runFunction: { dataFromUTF8View ( $0* 200 , from: largeUnicodeString) } , tags: d,
182
+ legacyFactor: 50 ) ,
183
+
184
+ BenchmarkInfo ( name: " StringToDataUsingUTF8EncodingEmpty " ,
185
+ runFunction: { dataUsingUTF8Encoding ( $0* 200 , from: emptyString) } , tags: d,
186
+ legacyFactor: 50 ) ,
187
+ BenchmarkInfo ( name: " StringToDataUsingUTF8EncodingSmall " ,
188
+ runFunction: { dataUsingUTF8Encoding ( $0* 200 , from: smallString) } , tags: d,
189
+ legacyFactor: 50 ) ,
190
+ BenchmarkInfo ( name: " StringToDataUsingUTF8EncodingMedium " ,
191
+ runFunction: { dataUsingUTF8Encoding ( $0* 200 , from: mediumString) } , tags: d,
192
+ legacyFactor: 50 ) ,
193
+ BenchmarkInfo ( name: " StringToDataUsingUTF8EncodingLargeUnicode " ,
194
+ runFunction: { dataUsingUTF8Encoding ( $0* 200 , from: largeUnicodeString) } , tags: d,
182
195
legacyFactor: 50 ) ,
183
196
184
197
BenchmarkInfo ( name: " Data.hash.Empty " ,
@@ -397,12 +410,19 @@ public func string(_ N: Int, from data: Data) {
397
410
}
398
411
399
412
@inline ( never)
400
- public func data ( _ N: Int , from string: String ) {
413
+ public func dataFromUTF8View ( _ N: Int , from string: String ) {
401
414
for _ in 1 ... N {
402
415
blackHole ( Data ( string. utf8) )
403
416
}
404
417
}
405
418
419
+ @inline ( never)
420
+ public func dataUsingUTF8Encoding( _ N: Int , from string: String ) {
421
+ for _ in 1 ... N {
422
+ blackHole ( string. data ( using: . utf8) )
423
+ }
424
+ }
425
+
406
426
@inline ( never)
407
427
public func hash( _ N: Int , data: Data ) {
408
428
var hasher = Hasher ( )
0 commit comments