-
Notifications
You must be signed in to change notification settings - Fork 2.1k
log messages periodically (time-based) #669
Conversation
sergiud
left a comment
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.
Thanks for the PR. Could you please add tests?
b8ef152 to
447b97d
Compare
Done. hopefully they're sufficient. |
|
There are some build failures. |
497f1f4 to
fd83d3c
Compare
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.
Looks mostly fine. I still have a few remarks. Could you please eventually squash the commits?
src/logging_unittest.cc
Outdated
| return stream; | ||
| } | ||
| // get elapsed time in microseconds | ||
| int64 elapsedTime_us(const timespec& begin, const timespec& end) { |
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.
This is something I previously overlooked. Wouldn't it make sense to always you the highest possible precision in ns?
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.
Not for this particular test, because the error tolerance is 500us and any variation in the hundreds of nanoseconds is insignificant. That being said, I'll go back and change to nanoseconds to remove some of the math just to simply the functions.
Yeah I'll do that. One last thing... |
|
You can still define |
|
That'll be plan B. Do you think it's fair to say for |
|
I would prefer |
3b244db to
ff2269a
Compare
Use <chrono> and <atomic> for C++11 or greater. For non-Windows pre-C++11 systems, use <time.h> and built-in atomic operations. For Windows pre-C++11, use the Windows implementations for time and atomic operations.
ff2269a to
a1374c4
Compare
|
Thanks! |
Closes #663
constexprif c++11, otherwiseconststd::chronoandstd::atomicstruct timespecfrom<ctime>or<time.h>on Linux platforms. On Windows platforms, useQueryPerformanceCounterandQueryPerformanceFrequency