Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Moved Timer impl back to cpp

(I thought it wasn't included on the non-main path, but it is)
Commit
a1e3f0b62446afe9b46b0872d373ab0e4e8a4357
Author
Phil Nash ·
Parents
39d37d9f341e

Files · Download .tar.gz

Changes

 include/internal/catch_timer.cpp | 17 +++++++++++++++++
 include/internal/catch_timer.h   | 20 +++++---------------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/include/internal/catch_timer.cpp b/include/internal/catch_timer.cpp
index fad86f85..ca09d7bc 100644
--- a/include/internal/catch_timer.cpp
+++ b/include/internal/catch_timer.cpp
@@ -16,4 +16,21 @@ namespace Catch {
         return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
     }
 
+        void Timer::start() {
+           m_nanoseconds = getCurrentNanosecondsSinceEpoch();
+        }
+        auto Timer::getElapsedNanoseconds() const -> unsigned int {
+            return static_cast<unsigned int>(getCurrentNanosecondsSinceEpoch() - m_nanoseconds);
+        }
+        auto Timer::getElapsedMicroseconds() const -> unsigned int {
+            return static_cast<unsigned int>(getElapsedNanoseconds()/1000);
+        }
+        auto Timer::getElapsedMilliseconds() const -> unsigned int {
+            return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
+        }
+        auto Timer::getElapsedSeconds() const -> double {
+            return getElapsedMicroseconds()/1000000.0;
+        }
+
+
 } // namespace Catch
diff --git a/include/internal/catch_timer.h b/include/internal/catch_timer.h
index d9c381c1..09182866 100644
--- a/include/internal/catch_timer.h
+++ b/include/internal/catch_timer.h
@@ -17,21 +17,11 @@ namespace Catch {
     class Timer {
         uint64_t m_nanoseconds = 0;
     public:
-        void start() {
-           m_nanoseconds = getCurrentNanosecondsSinceEpoch();
-        }
-        auto getElapsedNanoseconds() const -> unsigned int {
-            return static_cast<unsigned int>(getCurrentNanosecondsSinceEpoch() - m_nanoseconds);
-        }
-        auto getElapsedMicroseconds() const -> unsigned int {
-            return static_cast<unsigned int>(getElapsedNanoseconds()/1000);
-        }
-        auto getElapsedMilliseconds() const -> unsigned int {
-            return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
-        }
-        auto getElapsedSeconds() const -> double {
-            return getElapsedMicroseconds()/1000000.0;
-        }
+        void start();
+        auto getElapsedNanoseconds() const -> unsigned int;
+        auto getElapsedMicroseconds() const -> unsigned int;
+        auto getElapsedMilliseconds() const -> unsigned int;
+        auto getElapsedSeconds() const -> double;
     };
 
 } // namespace Catch