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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2017-08-04 12:22:16 +0100
committerPhil Nash2017-08-04 12:22:16 +0100
commit39d37d9f341e0cefc52a2abfdefbe1071fe0bc56 (patch)
tree3cda55e7739737e42beeaf8981a561df6fdf6861 /include
parentc7028f7bc76e011f23fcc2baf308f5c27ef1f019 (diff)
downloadcatch3-39d37d9f341e0cefc52a2abfdefbe1071fe0bc56.tar.gz
Timer resolution is now nanoseconds
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_timer.cpp4
-rw-r--r--include/internal/catch_timer.h11
2 files changed, 9 insertions, 6 deletions
diff --git a/include/internal/catch_timer.cpp b/include/internal/catch_timer.cpp
index 3253f1f4..fad86f85 100644
--- a/include/internal/catch_timer.cpp
+++ b/include/internal/catch_timer.cpp
@@ -12,8 +12,8 @@
namespace Catch {
- auto getCurrentMicrosecondsSinceEpoch() -> uint64_t {
- return std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
+ auto getCurrentNanosecondsSinceEpoch() -> uint64_t {
+ return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
}
} // namespace Catch
diff --git a/include/internal/catch_timer.h b/include/internal/catch_timer.h
index 2533b02f..d9c381c1 100644
--- a/include/internal/catch_timer.h
+++ b/include/internal/catch_timer.h
@@ -12,16 +12,19 @@
namespace Catch {
- auto getCurrentMicrosecondsSinceEpoch() -> uint64_t;
+ auto getCurrentNanosecondsSinceEpoch() -> uint64_t;
class Timer {
- uint64_t m_microSeconds = 0;
+ uint64_t m_nanoseconds = 0;
public:
void start() {
- m_microSeconds = getCurrentMicrosecondsSinceEpoch();
+ 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>(getCurrentMicrosecondsSinceEpoch() - m_microSeconds);
+ return static_cast<unsigned int>(getElapsedNanoseconds()/1000);
}
auto getElapsedMilliseconds() const -> unsigned int {
return static_cast<unsigned int>(getElapsedMicroseconds()/1000);