Skip to content

Commit 661a4c6

Browse files
committed
[benchmark] DataAppendSequence refactored
Refactored to use shareable test method and inlined runFunction.
1 parent f239f19 commit 661a4c6

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

benchmark/single-source/DataBenchmarks.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public let DataBenchmarks = [
9595
runFunction: run_ReplaceLargeBuffer, tags: skip),
9696

9797
BenchmarkInfo(name: "DataAppendSequence",
98-
runFunction: run_AppendSequence, tags: d),
98+
runFunction: { append($0, sequenceLength: 809, to: medium) }, tags: d),
9999

100100
BenchmarkInfo(name: "DataAppendDataSmallToSmall",
101101
runFunction: { append($0, data: small, to: small) }, tags: d),
@@ -232,11 +232,12 @@ func append(_ N: Int, arraySize: Int, to data: Data) {
232232
}
233233
}
234234

235-
func benchmark_AppendSequence(_ N: Int, _ count: Int, _ data_: Data) {
236-
let bytes = repeatElement(UInt8(0xA0), count: count)
235+
@inline(never)
236+
func append(_ N: Int, sequenceLength: Int, to data: Data) {
237+
let bytes = repeatElement(UInt8(0xA0), count: sequenceLength)
237238
for _ in 0..<10000*N {
238-
var data = data_
239-
data.append(contentsOf: bytes)
239+
var copy = data
240+
copy.append(contentsOf: bytes)
240241
}
241242
}
242243

@@ -345,12 +346,6 @@ public func run_ReplaceLargeBuffer(_ N: Int) {
345346
}
346347
}
347348

348-
@inline(never)
349-
public func run_AppendSequence(_ N: Int) {
350-
let data = sampleData(.medium)
351-
benchmark_AppendSequence(N, 809, data)
352-
}
353-
354349
@inline(never)
355350
public func run_DataToStringEmpty(_ N: Int) {
356351
let d = Data()

0 commit comments

Comments
 (0)