Skip to content

Commit b61a63d

Browse files
committed
[benchmark] Add docs & adjust loop multipliers
Bumping up the multipliers to get above 20 μs runtime.
1 parent 0ac591e commit b61a63d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

benchmark/single-source/ExistentialPerformance.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818

1919
import TestsUtils
2020

21+
// The purpose of these benchmarks is to evaluate different scenarios when
22+
// moving the implementation of existentials (protocol values) to heap based
23+
// copy-on-write buffers.
24+
//
25+
// The performance boost of `Ref4` vs `Ref3` is expected because copying the
26+
// existential only involves copying one reference of the heap based
27+
// copy-on-write buffer (outline case) that holds the struct vs copying the
28+
// individual fields of the struct in the inline case of `Ref3`.
29+
2130
let t: [BenchmarkCategory] = [.existential]
2231
let ta: [BenchmarkCategory] = [.api, .Array, .existential]
2332

@@ -525,7 +534,7 @@ func run_MutatingAndNonMutating(_ N: Int) {
525534

526535
func run_Array_init(_ N: Int) {
527536

528-
for _ in 0 ..< N * 20 {
537+
for _ in 0 ..< N * 100 {
529538
blackHole(Array(repeating: existentialType.init(), count: 128))
530539
}
531540
}
@@ -565,7 +574,7 @@ func run_ArrayMutating(_ N: Int) {
565574

566575
func run_ArrayShift(_ N: Int) {
567576
var existentialArray = grabArray()
568-
for _ in 0 ..< N * 10 {
577+
for _ in 0 ..< N * 25 {
569578
for i in 0 ..< existentialArray.count-1 {
570579
existentialArray.swapAt(i, i+1)
571580
}
@@ -574,7 +583,7 @@ func run_ArrayShift(_ N: Int) {
574583

575584
func run_ArrayConditionalShift(_ N: Int) {
576585
var existentialArray = grabArray()
577-
for _ in 0 ..< N * 10 {
586+
for _ in 0 ..< N * 25 {
578587
for i in 0 ..< existentialArray.count-1 {
579588
let curr = existentialArray[i]
580589
if curr.doIt() {

benchmark/single-source/ExistentialPerformance.swift.gyb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
import TestsUtils
2121

22+
// The purpose of these benchmarks is to evaluate different scenarios when
23+
// moving the implementation of existentials (protocol values) to heap based
24+
// copy-on-write buffers.
25+
//
26+
// The performance boost of `Ref4` vs `Ref3` is expected because copying the
27+
// existential only involves copying one reference of the heap based
28+
// copy-on-write buffer (outline case) that holds the struct vs copying the
29+
// individual fields of the struct in the inline case of `Ref3`.
30+
2231
let t: [BenchmarkCategory] = [.existential]
2332
let ta: [BenchmarkCategory] = [.api, .Array, .existential]
2433

@@ -64,7 +73,7 @@ Workloads = [
6473
fatalError("expected true")
6574
}
6675
"""),
67-
('Array.init', Setup[0], '20', """
76+
('Array.init', Setup[0], '100', """
6877
blackHole(Array(repeating: existentialType.init(), count: 128))
6978
"""),
7079
('Array.method.1x', Setup[4], '100', """
@@ -88,12 +97,12 @@ Workloads = [
8897
}
8998
}
9099
"""),
91-
('Array.Shift', Setup[5], '10', """
100+
('Array.Shift', Setup[5], '25', """
92101
for i in 0 ..< existentialArray.count-1 {
93102
existentialArray.swapAt(i, i+1)
94103
}
95104
"""),
96-
('Array.ConditionalShift', Setup[5], '10', """
105+
('Array.ConditionalShift', Setup[5], '25', """
97106
for i in 0 ..< existentialArray.count-1 {
98107
let curr = existentialArray[i]
99108
if curr.doIt() {

0 commit comments

Comments
 (0)