Skip to content

[benchmark] Add benchmark for generic floating-point to integer conversion #33895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions benchmark/single-source/FloatingPointConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public let FloatingPointConversion = [
runFunction: run_ConvertFloatingPoint_MockFloat64ToDouble,
tags: [.validation, .api],
setUpFunction: { blackHole(mockFloat64s) }),
BenchmarkInfo(
name: "ConvertFloatingPoint.MockFloat64ToInt64",
runFunction: run_ConvertFloatingPoint_MockFloat64ToInt64,
tags: [.validation, .api],
setUpFunction: { blackHole(mockFloat64s) }),
]

protocol MockBinaryFloatingPoint: BinaryFloatingPoint {
Expand Down Expand Up @@ -160,3 +165,13 @@ public func run_ConvertFloatingPoint_MockFloat64ToDouble(_ N: Int) {
}
}
}

@inline(never)
public func run_ConvertFloatingPoint_MockFloat64ToInt64(_ N: Int) {
for _ in 0..<(N * 1000) {
for element in mockFloat64s {
let i = Int64(identity(element))
blackHole(i)
}
}
}