diff options
| author | Phil Nash | 2017-08-04 13:53:47 +0100 |
|---|---|---|
| committer | Phil Nash | 2017-08-04 13:53:47 +0100 |
| commit | a1e3f0b62446afe9b46b0872d373ab0e4e8a4357 (patch) | |
| tree | 9a11a27b036f2cabe6e511b6158713b789197cb4 /include/internal/catch_timer.cpp | |
| parent | 39d37d9f341e0cefc52a2abfdefbe1071fe0bc56 (diff) | |
| download | catch3-a1e3f0b62446afe9b46b0872d373ab0e4e8a4357.tar.gz | |
Moved Timer impl back to cpp
(I thought it wasn't included on the non-main path, but it is)
Diffstat (limited to 'include/internal/catch_timer.cpp')
| -rw-r--r-- | include/internal/catch_timer.cpp | 17 |
1 files changed, 17 insertions, 0 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 |