Skip to content

Commit 4714a74

Browse files
author
Lance Parker
committed
Re-enable iterator benchmarks, remove longSharedPrefix from hashing benchmarks
1 parent 619673e commit 4714a74

File tree

2 files changed

+153
-23
lines changed

2 files changed

+153
-23
lines changed

benchmark/single-source/StringComparison.swift

Lines changed: 151 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ extension String {
3030
}
3131

3232

33-
// TODO(UTF8 post-merge): Disable longSharedPrefix hashing benchmark, which is
34-
// enabled here for 1-to-1 comparison vs master
35-
36-
// TODO(UTF8 post-merge): Enable NormalizedIteratorWorkloads for ["ascii",
37-
// "latin1", "fastPrenormal", "slowerPrenormal", "nonBMPSlowestPrenormal",
38-
// "emoji", "abnormal", "zalgo"]
3933

4034

4135
public let StringComparison: [BenchmarkInfo] = [
@@ -144,15 +138,57 @@ public let StringHashing: [BenchmarkInfo] = [
144138
tags: [.validation, .api, .String],
145139
setUpFunction: { blackHole(Workload_zalgo) }
146140
),
147-
BenchmarkInfo(
148-
name: "StringHashing_longSharedPrefix",
149-
runFunction: run_StringHashing_longSharedPrefix,
150-
tags: [.validation, .api, .String],
151-
setUpFunction: { blackHole(Workload_longSharedPrefix) }
152-
),
153141
]
154142

155143
public let NormalizedIterator: [BenchmarkInfo] = [
144+
BenchmarkInfo(
145+
name: "NormalizedIterator_ascii",
146+
runFunction: run_NormalizedIterator_ascii,
147+
tags: [.validation, .String],
148+
setUpFunction: { blackHole(Workload_ascii) }
149+
),
150+
BenchmarkInfo(
151+
name: "NormalizedIterator_latin1",
152+
runFunction: run_NormalizedIterator_latin1,
153+
tags: [.validation, .String],
154+
setUpFunction: { blackHole(Workload_latin1) }
155+
),
156+
BenchmarkInfo(
157+
name: "NormalizedIterator_fastPrenormal",
158+
runFunction: run_NormalizedIterator_fastPrenormal,
159+
tags: [.validation, .String],
160+
setUpFunction: { blackHole(Workload_fastPrenormal) }
161+
),
162+
BenchmarkInfo(
163+
name: "NormalizedIterator_slowerPrenormal",
164+
runFunction: run_NormalizedIterator_slowerPrenormal,
165+
tags: [.validation, .String],
166+
setUpFunction: { blackHole(Workload_slowerPrenormal) }
167+
),
168+
BenchmarkInfo(
169+
name: "NormalizedIterator_nonBMPSlowestPrenormal",
170+
runFunction: run_NormalizedIterator_nonBMPSlowestPrenormal,
171+
tags: [.validation, .String],
172+
setUpFunction: { blackHole(Workload_nonBMPSlowestPrenormal) }
173+
),
174+
BenchmarkInfo(
175+
name: "NormalizedIterator_emoji",
176+
runFunction: run_NormalizedIterator_emoji,
177+
tags: [.validation, .String],
178+
setUpFunction: { blackHole(Workload_emoji) }
179+
),
180+
BenchmarkInfo(
181+
name: "NormalizedIterator_abnormal",
182+
runFunction: run_NormalizedIterator_abnormal,
183+
tags: [.validation, .String],
184+
setUpFunction: { blackHole(Workload_abnormal) }
185+
),
186+
BenchmarkInfo(
187+
name: "NormalizedIterator_zalgo",
188+
runFunction: run_NormalizedIterator_zalgo,
189+
tags: [.validation, .String],
190+
setUpFunction: { blackHole(Workload_zalgo) }
191+
),
156192
]
157193

158194
var Workload_ascii: Workload! = Workload.ascii
@@ -397,18 +433,118 @@ public func run_StringHashing_zalgo(_ N: Int) {
397433
}
398434
}
399435

436+
400437
@inline(never)
401-
public func run_StringHashing_longSharedPrefix(_ N: Int) {
402-
let workload: Workload = Workload.longSharedPrefix
438+
public func run_NormalizedIterator_ascii(_ N: Int) {
439+
let workload: Workload = Workload.ascii
403440
let tripCount = workload.tripCount
404441
let payload = workload.payload
405442
for _ in 1...tripCount*N {
406443
for str in payload {
407-
blackHole(str.hashValue)
444+
str._withNFCCodeUnits { cu in
445+
blackHole(cu)
446+
}
447+
}
448+
}
449+
}
450+
451+
@inline(never)
452+
public func run_NormalizedIterator_latin1(_ N: Int) {
453+
let workload: Workload = Workload.latin1
454+
let tripCount = workload.tripCount
455+
let payload = workload.payload
456+
for _ in 1...tripCount*N {
457+
for str in payload {
458+
str._withNFCCodeUnits { cu in
459+
blackHole(cu)
460+
}
461+
}
462+
}
463+
}
464+
465+
@inline(never)
466+
public func run_NormalizedIterator_fastPrenormal(_ N: Int) {
467+
let workload: Workload = Workload.fastPrenormal
468+
let tripCount = workload.tripCount
469+
let payload = workload.payload
470+
for _ in 1...tripCount*N {
471+
for str in payload {
472+
str._withNFCCodeUnits { cu in
473+
blackHole(cu)
474+
}
408475
}
409476
}
410477
}
411478

479+
@inline(never)
480+
public func run_NormalizedIterator_slowerPrenormal(_ N: Int) {
481+
let workload: Workload = Workload.slowerPrenormal
482+
let tripCount = workload.tripCount
483+
let payload = workload.payload
484+
for _ in 1...tripCount*N {
485+
for str in payload {
486+
str._withNFCCodeUnits { cu in
487+
blackHole(cu)
488+
}
489+
}
490+
}
491+
}
492+
493+
@inline(never)
494+
public func run_NormalizedIterator_nonBMPSlowestPrenormal(_ N: Int) {
495+
let workload: Workload = Workload.nonBMPSlowestPrenormal
496+
let tripCount = workload.tripCount
497+
let payload = workload.payload
498+
for _ in 1...tripCount*N {
499+
for str in payload {
500+
str._withNFCCodeUnits { cu in
501+
blackHole(cu)
502+
}
503+
}
504+
}
505+
}
506+
507+
@inline(never)
508+
public func run_NormalizedIterator_emoji(_ N: Int) {
509+
let workload: Workload = Workload.emoji
510+
let tripCount = workload.tripCount
511+
let payload = workload.payload
512+
for _ in 1...tripCount*N {
513+
for str in payload {
514+
str._withNFCCodeUnits { cu in
515+
blackHole(cu)
516+
}
517+
}
518+
}
519+
}
520+
521+
@inline(never)
522+
public func run_NormalizedIterator_abnormal(_ N: Int) {
523+
let workload: Workload = Workload.abnormal
524+
let tripCount = workload.tripCount
525+
let payload = workload.payload
526+
for _ in 1...tripCount*N {
527+
for str in payload {
528+
str._withNFCCodeUnits { cu in
529+
blackHole(cu)
530+
}
531+
}
532+
}
533+
}
534+
535+
@inline(never)
536+
public func run_NormalizedIterator_zalgo(_ N: Int) {
537+
let workload: Workload = Workload.zalgo
538+
let tripCount = workload.tripCount
539+
let payload = workload.payload
540+
for _ in 1...tripCount*N {
541+
for str in payload {
542+
str._withNFCCodeUnits { cu in
543+
blackHole(cu)
544+
}
545+
}
546+
}
547+
}
412548

413549

414550
struct Workload {

benchmark/single-source/StringComparison.swift.gyb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,10 @@ extension String {
3232

3333
% AllWorkloads = ["ascii", "latin1", "fastPrenormal", "slowerPrenormal", "nonBMPSlowestPrenormal", "emoji", "abnormal", "zalgo", "longSharedPrefix"]
3434
% ComparisonWorkloads = AllWorkloads
35-
% HashingWorkloads = ["ascii", "latin1", "fastPrenormal", "slowerPrenormal", "nonBMPSlowestPrenormal", "emoji", "abnormal", "zalgo", "longSharedPrefix"]
35+
% HashingWorkloads = ["ascii", "latin1", "fastPrenormal", "slowerPrenormal", "nonBMPSlowestPrenormal", "emoji", "abnormal", "zalgo"]
3636

37-
// TODO(UTF8 post-merge): Disable longSharedPrefix hashing benchmark, which is
38-
// enabled here for 1-to-1 comparison vs master
3937

40-
// TODO(UTF8 post-merge): Enable NormalizedIteratorWorkloads for ["ascii",
41-
// "latin1", "fastPrenormal", "slowerPrenormal", "nonBMPSlowestPrenormal",
42-
// "emoji", "abnormal", "zalgo"]
43-
44-
% NormalizedIteratorWorkloads = []
38+
% NormalizedIteratorWorkloads = ["ascii", "latin1", "fastPrenormal", "slowerPrenormal", "nonBMPSlowestPrenormal", "emoji", "abnormal", "zalgo"]
4539

4640
public let StringComparison: [BenchmarkInfo] = [
4741
% for Name in ComparisonWorkloads:

0 commit comments

Comments
 (0)