-
Notifications
You must be signed in to change notification settings - Fork 226
Avoid integer overflow with infinite time limit in CPU Feasibility Jump #1844
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1895,7 +1895,9 @@ void cpufj_solve(fj_cpu_climber_t<i_t, f_t>* fj_cpu, f_t in_time_limit, double w | |
| { | ||
| i_t local_mins = 0; | ||
| auto loop_start = std::chrono::high_resolution_clock::now(); | ||
| auto time_limit = std::chrono::milliseconds(static_cast<i_t>(std::floor(in_time_limit * 1000.0))); | ||
| auto time_limit = (in_time_limit < std::numeric_limits<f_t>::infinity()) | ||
| ? std::chrono::milliseconds(static_cast<i_t>(std::floor(in_time_limit * 1000.0))) | ||
| : std::chrono::milliseconds::max(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Add regression tests for the duration boundary cases. Add gtest coverage for the default positive-infinite limit, a normal finite limit, and an oversized finite limit. Set the iteration limit so the tests do not depend on wall-clock timing. As per coding guidelines: “ 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| auto loop_time_start = std::chrono::high_resolution_clock::now(); | ||
|
|
||
| fj_cpu->rng.seed(fj_cpu->settings.seed); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.