Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_timer.cpp
diff options
context:
space:
mode:
authorPhil Nash2017-08-04 13:53:47 +0100
committerPhil Nash2017-08-04 13:53:47 +0100
commita1e3f0b62446afe9b46b0872d373ab0e4e8a4357 (patch)
tree9a11a27b036f2cabe6e511b6158713b789197cb4 /include/internal/catch_timer.cpp
parent39d37d9f341e0cefc52a2abfdefbe1071fe0bc56 (diff)
downloadcatch3-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.cpp17
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