Skip to content

Commit 21baf46

Browse files
committed
[benchmark] DataCreate refactored
Refactored to use inlined runFunctions.
1 parent c8da0a9 commit 21baf46

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

benchmark/single-source/DataBenchmarks.swift

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ let skip: [BenchmarkCategory] = [.validation, .api, .Data, .skip]
1818

1919
public let DataBenchmarks = [
2020
BenchmarkInfo(name: "DataCreateEmpty",
21-
runFunction: run_createEmpty, tags: d),
21+
runFunction: { for _ in 0..<$0*100_000 { blackHole(Data()) } }, tags: d),
2222
BenchmarkInfo(name: "DataCreateSmall",
23-
runFunction: run_createSmall, tags: d),
23+
runFunction: { for _ in 0..<$0*100_000 { blackHole(sampleData(.small)) } },
24+
tags: d),
2425
BenchmarkInfo(name: "DataCreateMedium",
25-
runFunction: run_createMedium, tags: d),
26+
runFunction: { for _ in 0..<$0*10_000 { blackHole(sampleData(.medium)) } },
27+
tags: d),
2628

2729
BenchmarkInfo(name: "DataCreateEmptyArray",
2830
runFunction: { for _ in 0..<$0*100_000 { blackHole(Data([])) } }, tags: d),
@@ -416,27 +418,6 @@ public func run_AppendDataLargeToLarge(_ N: Int) {
416418
benchmark_AppendData(N, data, other)
417419
}
418420

419-
@inline(never)
420-
public func run_createEmpty(_ N: Int) {
421-
for _ in 0..<100000 * N {
422-
blackHole(Data())
423-
}
424-
}
425-
426-
@inline(never)
427-
public func run_createSmall(_ N: Int) {
428-
for _ in 0..<100000 * N {
429-
blackHole(sampleData(.small))
430-
}
431-
}
432-
433-
@inline(never)
434-
public func run_createMedium(_ N: Int) {
435-
for _ in 0..<10000 * N {
436-
blackHole(sampleData(.medium))
437-
}
438-
}
439-
440421
@inline(never)
441422
public func run_DataToStringEmpty(_ N: Int) {
442423
let d = Data()

0 commit comments

Comments
 (0)