Skip to content

Commit 93c9a64

Browse files
committed
Leave only tests for buffer of length 7, 15 and 1000 bytes; Increase multiplier from 10 to 10000
1 parent 136baaf commit 93c9a64

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

benchmark/single-source/BufferFind.swift

+16-34
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313
import TestsUtils
1414

1515
public var benchmarks: [BenchmarkInfo] = [
16-
BenchmarkInfo(
17-
name: "RawBuffer.100000.findFirst",
18-
runFunction: run_BufferFindFirst,
19-
tags: [.validation, .api],
20-
setUpFunction: buffer100000Setup,
21-
tearDownFunction: bufferTeardown
22-
),
23-
BenchmarkInfo(
24-
name: "RawBuffer.100000.findLast",
25-
runFunction: run_BufferFindLast,
26-
tags: [.validation, .api],
27-
setUpFunction: buffer100000Setup,
28-
tearDownFunction: bufferTeardown
29-
),
3016
// size 1000, alignment 0
3117
BenchmarkInfo(
3218
name: "RawBuffer.1000.findFirst",
@@ -42,54 +28,50 @@ public var benchmarks: [BenchmarkInfo] = [
4228
setUpFunction: buffer1000Setup,
4329
tearDownFunction: bufferTeardown
4430
),
45-
// size 100, alignment 0
31+
// size 15, alignment 0
4632
BenchmarkInfo(
47-
name: "RawBuffer.100.findFirst",
33+
name: "RawBuffer.15.findFirst",
4834
runFunction: run_BufferFindFirst,
4935
tags: [.validation, .api],
50-
setUpFunction: buffer100Setup,
36+
setUpFunction: buffer15Setup,
5137
tearDownFunction: bufferTeardown
5238
),
5339
BenchmarkInfo(
54-
name: "RawBuffer.100.findLast",
40+
name: "RawBuffer.15.findLast",
5541
runFunction: run_BufferFindLast,
5642
tags: [.validation, .api],
57-
setUpFunction: buffer100Setup,
43+
setUpFunction: buffer15Setup,
5844
tearDownFunction: bufferTeardown
5945
),
60-
// size 10, alignment 0
46+
// size 7, alignment 0
6147
BenchmarkInfo(
62-
name: "RawBuffer.10.findFirst",
48+
name: "RawBuffer.7.findFirst",
6349
runFunction: run_BufferFindFirst,
6450
tags: [.validation, .api],
65-
setUpFunction: buffer10Setup,
51+
setUpFunction: buffer7Setup,
6652
tearDownFunction: bufferTeardown
6753
),
6854
BenchmarkInfo(
69-
name: "RawBuffer.10.findLast",
55+
name: "RawBuffer.7.findLast",
7056
runFunction: run_BufferFindLast,
7157
tags: [.validation, .api],
72-
setUpFunction: buffer10Setup,
58+
setUpFunction: buffer7Setup,
7359
tearDownFunction: bufferTeardown
7460
)
7561
]
7662

7763
var buffer: UnsafeMutableRawBufferPointer = .init(start: nil, count: 0)
7864

79-
func buffer100000Setup() {
80-
bufferSetup(size: 100_000, alignment: 0)
81-
}
82-
8365
func buffer1000Setup() {
8466
bufferSetup(size: 1000, alignment: 0)
8567
}
8668

87-
func buffer100Setup() {
88-
bufferSetup(size: 100, alignment: 0)
69+
func buffer15Setup() {
70+
bufferSetup(size: 15, alignment: 0)
8971
}
9072

91-
func buffer10Setup() {
92-
bufferSetup(size: 10, alignment: 0)
73+
func buffer7Setup() {
74+
bufferSetup(size: 7, alignment: 0)
9375
}
9476

9577
func bufferTeardown() {
@@ -106,7 +88,7 @@ func bufferSetup(size: Int, alignment: Int) {
10688
@inline(never)
10789
public func run_BufferFindFirst(n: Int) {
10890
var offset = 0
109-
for _ in 0 ..< n * 10 {
91+
for _ in 0 ..< n * 10_000 {
11092
if let index = buffer.firstIndex(of: UInt8.max) {
11193
offset += index
11294
}
@@ -117,7 +99,7 @@ public func run_BufferFindFirst(n: Int) {
11799
@inline(never)
118100
public func run_BufferFindLast(n: Int) {
119101
var offset = 0
120-
for _ in 0 ..< n * 10 {
102+
for _ in 0 ..< n * 10_000 {
121103
if let index = buffer.lastIndex(of: UInt8.max) {
122104
offset += index
123105
}

0 commit comments

Comments
 (0)