From 60cde2e5fc6745bdf7d0f974c030dfa9349d0f4d Mon Sep 17 00:00:00 2001 From: odygrd Date: Fri, 20 Sep 2024 11:26:26 +0100 Subject: [PATCH] fix compile error in `BackendTscClock` --- examples/backend_tsc_clock.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/backend_tsc_clock.cpp b/examples/backend_tsc_clock.cpp index 3d710615..e9b8827c 100644 --- a/examples/backend_tsc_clock.cpp +++ b/examples/backend_tsc_clock.cpp @@ -33,9 +33,11 @@ int main() logger->flush_log(); // Log both the backend TSC clock epoch time and the current system clock epoch time + auto const backend_tsc_epoch_ns = quill::BackendTscClock::now().time_since_epoch().count(); + auto const system_epoch_ns = std::chrono::system_clock::now().time_since_epoch().count(); + LOG_INFO(logger, "Backend TSC clock epoch time: {} ns, System clock epoch time: {} ns", - quill::BackendTscClock::now().time_since_epoch().count(), - std::chrono::system_clock::now().time_since_epoch().count()); + backend_tsc_epoch_ns, system_epoch_ns); // Get the current TSC timestamp now auto const tsc_start = quill::BackendTscClock::rdtsc(); @@ -46,12 +48,16 @@ int main() // Get another TSC timestamp after the delay auto const tsc_end = quill::BackendTscClock::rdtsc(); - // Convert the TSC timestamps to seconds since the epoch and log them + // Convert the TSC timestamps to seconds since the epoch + auto const tsc_start_seconds = std::chrono::duration_cast( + quill::BackendTscClock::to_time_point(tsc_start).time_since_epoch()) + .count(); + + auto const tsc_end_seconds = std::chrono::duration_cast( + quill::BackendTscClock::to_time_point(tsc_end).time_since_epoch()) + .count(); + + // Log the TSC timestamps before and after the delay LOG_INFO(logger, "Initial TSC timestamp: {} seconds, Final TSC timestamp after delay: {} seconds", - std::chrono::duration_cast( - quill::BackendTscClock::to_time_point(tsc_start).time_since_epoch()) - .count(), - std::chrono::duration_cast( - quill::BackendTscClock::to_time_point(tsc_end).time_since_epoch()) - .count()); + tsc_start_seconds, tsc_end_seconds); } \ No newline at end of file