From 9b01c8bf8651a5a23a64b0861bd846d122256b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Tue, 5 Jul 2022 18:53:23 +0200 Subject: [PATCH] Use Genode timer_session as time source. --- src/mx/tasking/profiling/profiling_task.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mx/tasking/profiling/profiling_task.h b/src/mx/tasking/profiling/profiling_task.h index 23381d4..e7ad9f4 100644 --- a/src/mx/tasking/profiling/profiling_task.h +++ b/src/mx/tasking/profiling/profiling_task.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -9,21 +9,21 @@ #include namespace mx::tasking::profiling { - /* TODO: Replace std::chrono with a Genode timer session */ + /* DONE: Replace std::chrono with a Genode timer session */ /** * Time range (from -- to) for idled time of a single channel. */ class IdleRange { public: - IdleRange() : _start(std::chrono::steady_clock::now()) {} + IdleRange() : _timer(Timer::Connection(system::Environment::env)), _start(std::chrono::microseconds(_timer.elapsed_ms())) {} IdleRange(IdleRange &&) = default; ~IdleRange() = default; /** * Sets the end of the idle range to the current time. */ - void stop() noexcept { _end = std::chrono::steady_clock::now(); } + void stop() noexcept { _end = std::chrono::time_point(std::chrono::microseconds(_timer.elapsed_us())); } /** * @return Number of nanoseconds idled. @@ -53,6 +53,9 @@ private: // End of idling. std::chrono::steady_clock::time_point _end; + + // Timer session for Genode + Timer::Connection _timer; }; /**