Skip to content

Commit 41d0e29

Browse files
authored
[benchmark] Add benchmark for generic floating-point to integer conversion (#33895)
* [benchmark] Add a benchmark for generic floating-point to integer conversion * [benchmark] Increase workload on new benchmark before merging
1 parent a0c529a commit 41d0e29

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

benchmark/single-source/FloatingPointConversion.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public let FloatingPointConversion = [
1818
runFunction: run_ConvertFloatingPoint_MockFloat64ToDouble,
1919
tags: [.validation, .api],
2020
setUpFunction: { blackHole(mockFloat64s) }),
21+
BenchmarkInfo(
22+
name: "ConvertFloatingPoint.MockFloat64ToInt64",
23+
runFunction: run_ConvertFloatingPoint_MockFloat64ToInt64,
24+
tags: [.validation, .api],
25+
setUpFunction: { blackHole(mockFloat64s) }),
2126
]
2227

2328
protocol MockBinaryFloatingPoint: BinaryFloatingPoint {
@@ -160,3 +165,13 @@ public func run_ConvertFloatingPoint_MockFloat64ToDouble(_ N: Int) {
160165
}
161166
}
162167
}
168+
169+
@inline(never)
170+
public func run_ConvertFloatingPoint_MockFloat64ToInt64(_ N: Int) {
171+
for _ in 0..<(N * 1000) {
172+
for element in mockFloat64s {
173+
let i = Int64(identity(element))
174+
blackHole(i)
175+
}
176+
}
177+
}

0 commit comments

Comments
 (0)