From 3a13b22b118e45990d4bce8b54bfb4c7c1e9a53c Mon Sep 17 00:00:00 2001 From: Sylar Date: Sun, 2 Nov 2025 19:08:59 +0100 Subject: [PATCH] Added ability to read ostd::Timer without stopping it --- other/build.nr | 2 +- src/ostd/Utils.cpp | 4 ++-- src/ostd/Utils.hpp | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/other/build.nr b/other/build.nr index 0717cf7..f0a82b4 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -1902 +1904 diff --git a/src/ostd/Utils.cpp b/src/ostd/Utils.cpp index 9a4092a..b275aef 100755 --- a/src/ostd/Utils.cpp +++ b/src/ostd/Utils.cpp @@ -552,10 +552,10 @@ namespace ostd return diff; } - uint64_t Timer::endCount(void) + uint64_t Timer::endCount(bool stop) { if (!m_started) return 0; - m_started = false; + m_started = !stop; int64_t diff; switch (m_timeUnit) { diff --git a/src/ostd/Utils.hpp b/src/ostd/Utils.hpp index 4011293..56a9635 100755 --- a/src/ostd/Utils.hpp +++ b/src/ostd/Utils.hpp @@ -1,6 +1,7 @@ #ifndef __DATATYPES__HPP__ #define __DATATYPES__HPP__ +#include #include #include #include @@ -74,11 +75,12 @@ namespace ostd uint64_t start(bool print = true, String name = "", eTimeUnits timeUnit = eTimeUnits::Nanoseconds, OutputHandlerBase* __destination = nullptr); uint64_t startCount(eTimeUnits timeUnit = eTimeUnits::Nanoseconds); uint64_t end(bool print = true); - uint64_t endCount(void); + uint64_t endCount(bool stop = true); static uint64_t getEpoch(eTimeUnits timeUnit = eTimeUnits::Milliseconds); inline const String& getName(void) const { return m_name; } + inline uint64_t read(void) { if (!m_started) return 0; return endCount(false); } private: bool m_started; @@ -194,7 +196,7 @@ namespace ostd static std::vector listDirectoriesInDirectoryRecursive(const String& directoryPath); static std::vector listDirectoryRecursive(const String& directoryPath); static ostd::String getHomeDirPath(void); - + //Implemented in static int32_t solveIntegerExpression(const String& expr);