diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2016-10-10 23:07:29 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2016-10-10 23:07:29 -0700 |
| commit | 9e1d40e4dc313de2e6de0ac4f60a2df224215ae2 (patch) | |
| tree | bc60827a29151d7829f4b6fdeaa8d6f60e8f8258 /toolsrc/include | |
| parent | c494892eb24ce6f84c777f24dfceb71a4988fd24 (diff) | |
| parent | 23f187a45766057ef76baba9dc912270b403cb7d (diff) | |
| download | vcpkg-9e1d40e4dc313de2e6de0ac4f60a2df224215ae2.tar.gz vcpkg-9e1d40e4dc313de2e6de0ac4f60a2df224215ae2.zip | |
Merge branch 'master' of https://github.com/microsoft/vcpkg
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/Stopwatch.h | 40 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Strings.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_System.h | 2 |
3 files changed, 46 insertions, 1 deletions
diff --git a/toolsrc/include/Stopwatch.h b/toolsrc/include/Stopwatch.h new file mode 100644 index 000000000..2bd5c31bf --- /dev/null +++ b/toolsrc/include/Stopwatch.h @@ -0,0 +1,40 @@ +#pragma once + +#include <chrono> +#include <string> + +namespace vcpkg +{ + class Stopwatch + { + public: + static Stopwatch createUnstarted(); + + static Stopwatch createStarted(); + + bool isRunning() const; + + Stopwatch& start(); + + Stopwatch& stop(); + + Stopwatch& reset(); + + template <class TimeUnit> + TimeUnit elapsed() const + { + return std::chrono::duration_cast<TimeUnit>(elapsedNanos()); + } + + std::string toString() const; + + private: + Stopwatch(); + + std::chrono::nanoseconds elapsedNanos() const; + + bool m_isRunning; + std::chrono::nanoseconds m_elapsedNanos; + std::chrono::steady_clock::time_point m_startTick; + }; +} diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h index 2aa99afe0..70526198c 100644 --- a/toolsrc/include/vcpkg_Strings.h +++ b/toolsrc/include/vcpkg_Strings.h @@ -19,6 +19,11 @@ namespace vcpkg {namespace Strings {namespace details return s; } + inline double to_printf_arg(const double s) + { + return s; + } + inline size_t to_printf_arg(const size_t s) { return s; diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h index f47fc9aab..c420464c1 100644 --- a/toolsrc/include/vcpkg_System.h +++ b/toolsrc/include/vcpkg_System.h @@ -64,7 +64,7 @@ namespace vcpkg {namespace System return println(c, Strings::format(messageTemplate, messageArgs...).c_str()); } - struct Stopwatch + struct Stopwatch2 { int64_t start_time, end_time, freq; |
