Skip to content

Commit a9d9fef

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

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

benchmark/single-source/DataBenchmarks.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public let DataBenchmarks = [
7878
runFunction: { append($0, arraySize: 809, to: medium) }, tags: d),
7979

8080
BenchmarkInfo(name: "DataReset",
81-
runFunction: run_Reset, tags: d),
81+
runFunction: { resetBytes($0, in: 431..<809, data: medium) }, tags: d),
8282

8383
BenchmarkInfo(name: "DataReplaceSmall",
8484
runFunction: run_ReplaceSmall, tags: d),
@@ -241,10 +241,11 @@ func append(_ N: Int, sequenceLength: Int, to data: Data) {
241241
}
242242
}
243243

244-
func benchmark_Reset(_ N: Int, _ range: Range<Data.Index>, _ data_: Data) {
244+
@inline(never)
245+
func resetBytes(_ N: Int, in range: Range<Data.Index>, data: Data) {
245246
for _ in 0..<10000*N {
246-
var data = data_
247-
data.resetBytes(in: range)
247+
var copy = data
248+
copy.resetBytes(in: range)
248249
}
249250
}
250251

@@ -289,12 +290,6 @@ public func setCount(_ N: Int, data: Data, extra: Int) {
289290
}
290291
}
291292

292-
@inline(never)
293-
public func run_Reset(_ N: Int) {
294-
let data = sampleData(.medium)
295-
benchmark_Reset(N, 431..<809, data)
296-
}
297-
298293
@inline(never)
299294
public func run_ReplaceSmall(_ N: Int) {
300295
let data = sampleData(.medium)

0 commit comments

Comments
 (0)