Skip to content

Commit e12dfe7

Browse files
committed
[benchmark] LF: ChainedFilterMap & FatCompactMap
1 parent 2fe31b3 commit e12dfe7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

benchmark/single-source/ChainedFilterMap.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import TestsUtils
22

33
public var ChainedFilterMap = [
4-
BenchmarkInfo(name: "ChainedFilterMap", runFunction: run_ChainedFilterMap, tags: [.algorithm]),
5-
BenchmarkInfo(name: "FatCompactMap", runFunction: run_FatCompactMap, tags: [.algorithm])
4+
BenchmarkInfo(name: "ChainedFilterMap", runFunction: run_ChainedFilterMap,
5+
tags: [.algorithm], setUpFunction: { blackHole(first100k) },
6+
legacyFactor: 9),
7+
BenchmarkInfo(name: "FatCompactMap", runFunction: run_FatCompactMap,
8+
tags: [.algorithm], setUpFunction: { blackHole(first100k) },
9+
legacyFactor: 10)
610
]
711

812
public let first100k = Array(0...100_000-1)
913

1014
@inline(never)
1115
public func run_ChainedFilterMap(_ N: Int) {
1216
var result = 0
13-
for _ in 1...10*N {
17+
for _ in 1...N {
1418
let numbers = first100k.lazy
1519
.filter { $0 % 3 == 0 }
1620
.map { $0 * 2 }
@@ -25,7 +29,7 @@ public func run_ChainedFilterMap(_ N: Int) {
2529
@inline(never)
2630
public func run_FatCompactMap(_ N: Int) {
2731
var result = 0
28-
for _ in 1...10*N {
32+
for _ in 1...N {
2933
let numbers = first100k.lazy
3034
.compactMap { (x: Int) -> Int? in
3135
if x % 3 != 0 { return nil }

0 commit comments

Comments
 (0)