Skip to content
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

Fix division by zero for low frequency timers for CV statistics #1724

Merged
merged 1 commit into from
Jan 3, 2024
Merged

Fix division by zero for low frequency timers for CV statistics #1724

merged 1 commit into from
Jan 3, 2024

Conversation

ivafanas
Copy link
Contributor

@ivafanas ivafanas commented Jan 2, 2024

clock_gettime resolution is implementation defined:
https://linux.die.net/man/3/clock_gettime

double StatisticsCV(const std::vector<double>& v) function gets vector of zeroes on system with low frequency timers in user_counters_tabular_test test BM_Counters_Tabular/repeats:2/threads:1_cv case. Division result is nan and test fails due to regexp mismatch.

Additionally, division by zero (even FP zero) is a UB in C++ and should be avoided.

Copy link

google-cla bot commented Jan 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@dmah42
Copy link
Member

dmah42 commented Jan 3, 2024

nice :) thanks.

@dmah42 dmah42 merged commit 2d2e07e into google:main Jan 3, 2024
79 of 80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants