-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Floating point random benchmark #33462
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
base: main
Are you sure you want to change the base?
Conversation
Syncing from upstream
Benchmarks for `0..<1` are now at [https://github.com/apple/swift/pull/33462](#33462)
| BenchmarkInfo(name: "RandomDoubleLCG", runFunction: run_RandomDoubleLCG, | ||
| tags: [.api], legacyFactor: 2), | ||
| BenchmarkInfo(name: "RandomDoubleUnitDef", runFunction: run_RandomDoubleUnitDef, | ||
| tags: [.api], legacyFactor: 100), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, newly added tests should not have a legacyFactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not an expert in this area, I was just copying the existing benchmarks with the intention and hope that the results would be directly comparable therewith.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I’ve removed the legacy factors from the new benchmarks.
|
As long as we're adding more tests here, I would like to also add the following cases:
|
Also removed unneeded legacy factors from new benchmarks, and reformatted the `RandomValues` array literal to make it more readable.
Okay, I’ve added benchmarks for those ranges. I also notice that most of these functions are identical except for the range, the RNG, and the number of iterations. So I’m thinking of making a helper function to avoid the repetition. I’m not super familiar with benchmarking though—is there any reason I shouldn’t do that? |
Thank you!
I think that's perfectly reasonable. Do make sure that it doesn't fall off a performance cliff, since we want to be benchmarking the RNG and transform, not the benchmark overhead, but I don't expect that it will. |
|
Does this look like a good approach? (And similar for LCG) |
|
Seems reasonable to me! |
In preparation for #33455, this PR adds benchmarks for generating random floating-point numbers in the interval
0..<1.