diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-16 16:29:52 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-16 16:29:52 -0800 |
| commit | a62558fb793a0c8e31c189f8f5eebe3fc5c83f58 (patch) | |
| tree | 8cc04969f4224973794293d4a692d45eae85b69d /toolsrc/include | |
| parent | 8a37cd9b1d881905e34b281dcab51bc2a94ecf2c (diff) | |
| download | vcpkg-a62558fb793a0c8e31c189f8f5eebe3fc5c83f58.tar.gz vcpkg-a62558fb793a0c8e31c189f8f5eebe3fc5c83f58.zip | |
Introduce ElapsedTime class
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/Stopwatch.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/toolsrc/include/Stopwatch.h b/toolsrc/include/Stopwatch.h index 105a4b1ee..e4ae121b3 100644 --- a/toolsrc/include/Stopwatch.h +++ b/toolsrc/include/Stopwatch.h @@ -5,6 +5,25 @@ namespace vcpkg { + class ElapsedTime + { + public: + static ElapsedTime createStarted(); + + constexpr ElapsedTime() :m_startTick() {} + + template <class TimeUnit> + TimeUnit elapsed() const + { + return std::chrono::duration_cast<TimeUnit>(std::chrono::high_resolution_clock::now() - this->m_startTick); + } + + std::string toString() const; + + private: + std::chrono::steady_clock::time_point m_startTick; + }; + class Stopwatch { public: |
