aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/vcpkg_Chrono.h
diff options
context:
space:
mode:
authorJan HrubĂ˝ <jhruby.web@gmail.com>2017-03-13 08:56:05 +0100
committerGitHub <noreply@github.com>2017-03-13 08:56:05 +0100
commit665f4118f603c5858217ed7a2f2f824b18ff4fc5 (patch)
treef0167041edf71e90f2331b5025f603392a8de67a /toolsrc/include/vcpkg_Chrono.h
parent1bec0fcb73073b5b1719f454c368a63f1bff625e (diff)
parent1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff)
downloadvcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.tar.gz
vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.zip
Merge pull request #1 from Microsoft/master
pull
Diffstat (limited to 'toolsrc/include/vcpkg_Chrono.h')
-rw-r--r--toolsrc/include/vcpkg_Chrono.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg_Chrono.h b/toolsrc/include/vcpkg_Chrono.h
new file mode 100644
index 000000000..a9d1bbbed
--- /dev/null
+++ b/toolsrc/include/vcpkg_Chrono.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <chrono>
+#include <string>
+
+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);
+ }
+
+ double microseconds() const
+ {
+ return elapsed<std::chrono::duration<double, std::micro>>().count();
+ }
+
+ std::string toString() const;
+
+ private:
+ std::chrono::high_resolution_clock::time_point m_startTick;
+ };
+}