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
Handle time
conversions from constants.
#148
Comments
Do not assume that the underlying clock precision is nanoseconds. Fixes: google#148
Knowing more about To create a std::chrono::nanoseconds duration_ns{nanos}; To create a TimestampClock::duration casted_dur = std::chrono::duration_cast<TimestampClock::duration>(duration_ns); Now that we have a duration in TimestampClock::time_point timestamp(casted_dur); A sample code for different casting scenarios: https://godbolt.org/z/5cEEoGdon references: |
Do not assume that the underlying clock precision is nanoseconds. Use regex to match timestamps in unit test to avoid inherent fp precision differences. Fixes: google#148
Do not assume that the underlying clock precision is nanoseconds. Use regex to match timestamps in unit test to avoid inherent fp precision differences. Fixes: #148
We use 2 different clocks,
TimestampClock
andDurationClock
. They are aliases forstd::chrono::system_clock
andstd::chrono::steady_clock
. I created a wrapper around these clocks to make them easier to work with. E.g: #134,I had 2 assumptions in mind when writing these classes.
First, the
DurationClock
andTimestampClock
have the same precision. This caused a bug on a system in which this didn't hold. I fixed it in #145 by casting the duration from one clock to the other.My second assumption was that the clocks always are in the nanoseconds precision. The second bug happens in this code:
The
Timestamp
class is a wrapper around aTimestampClock
. It has aFromNanoseconds()
factory method that receives an input and stores it in the underlyingTimestampClock::time_point
variable assuming theTimestampClock
has a nanoseconds precision. That is why this line of test fails in a system that has a different clock.https://github.com/google/vulkan-performance-layers/blob/main/layer/unittest/trace_event_log_tests.cc#L198
The text was updated successfully, but these errors were encountered: