diff --git a/Userland/Libraries/LibCore/ElapsedTimer.cpp b/Userland/Libraries/LibCore/ElapsedTimer.cpp index f82451bd80c..bc81d93be99 100644 --- a/Userland/Libraries/LibCore/ElapsedTimer.cpp +++ b/Userland/Libraries/LibCore/ElapsedTimer.cpp @@ -20,7 +20,7 @@ ElapsedTimer ElapsedTimer::start_new() void ElapsedTimer::start() { m_valid = true; - m_origin_time = m_precise ? MonotonicTime::now() : MonotonicTime::now_coarse(); + m_origin_time = m_timer_type == TimerType::Precise ? MonotonicTime::now() : MonotonicTime::now_coarse(); } void ElapsedTimer::reset() @@ -36,7 +36,7 @@ i64 ElapsedTimer::elapsed_milliseconds() const Duration ElapsedTimer::elapsed_time() const { VERIFY(is_valid()); - auto now = m_precise ? MonotonicTime::now() : MonotonicTime::now_coarse(); + auto now = m_timer_type == TimerType::Precise ? MonotonicTime::now() : MonotonicTime::now_coarse(); return now - m_origin_time; } diff --git a/Userland/Libraries/LibCore/ElapsedTimer.h b/Userland/Libraries/LibCore/ElapsedTimer.h index 1ed5d0e88ae..380e8bce049 100644 --- a/Userland/Libraries/LibCore/ElapsedTimer.h +++ b/Userland/Libraries/LibCore/ElapsedTimer.h @@ -10,12 +10,17 @@ namespace Core { +enum class TimerType { + Precise, + Coarse +}; + class ElapsedTimer { public: static ElapsedTimer start_new(); - ElapsedTimer(bool precise = false) - : m_precise(precise) + ElapsedTimer(TimerType timer_type = TimerType::Coarse) + : m_timer_type(timer_type) { } @@ -36,7 +41,7 @@ public: private: MonotonicTime m_origin_time { MonotonicTime::now() }; - bool m_precise { false }; + TimerType m_timer_type { TimerType::Coarse }; bool m_valid { false }; }; diff --git a/Userland/Utilities/abench.cpp b/Userland/Utilities/abench.cpp index 51d5432f91b..52ba06d77cc 100644 --- a/Userland/Utilities/abench.cpp +++ b/Userland/Utilities/abench.cpp @@ -39,7 +39,7 @@ ErrorOr serenity_main(Main::Arguments args) } auto loader = maybe_loader.release_value(); - Core::ElapsedTimer sample_timer { true }; + Core::ElapsedTimer sample_timer { Core::TimerType::Precise }; i64 total_loader_time = 0; int remaining_samples = sample_count > 0 ? sample_count : NumericLimits::max(); unsigned total_loaded_samples = 0; diff --git a/Userland/Utilities/dd.cpp b/Userland/Utilities/dd.cpp index cb5d289ff55..cdcddac1c0b 100644 --- a/Userland/Utilities/dd.cpp +++ b/Userland/Utilities/dd.cpp @@ -45,7 +45,7 @@ struct { size_t total_bytes_copied = 0; size_t total_blocks_in = 0, partial_blocks_in = 0; size_t total_blocks_out = 0, partial_blocks_out = 0; - Core::ElapsedTimer timer { true }; + Core::ElapsedTimer timer { Core::TimerType::Precise }; } statistics; static void closing_statistics() diff --git a/Userland/Utilities/traceroute.cpp b/Userland/Utilities/traceroute.cpp index 3a075237e34..02f34ab1142 100644 --- a/Userland/Utilities/traceroute.cpp +++ b/Userland/Utilities/traceroute.cpp @@ -78,7 +78,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // 0: got ttl exhausted response // -1: error or no response auto try_reach_host = [&](int ttl) -> ErrorOr { - Core::ElapsedTimer m_timer { true }; + Core::ElapsedTimer m_timer { Core::TimerType::Precise }; auto ttl_number = ByteString::number(ttl); for (auto i = 0; i < max_retries; i++) { icmp_request request {};