From a00500bcc15058e3379b7a74c2f0248ddfe74e0d Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 10 Oct 2016 15:03:48 -0700 Subject: Add to_printf_arg(double) overload --- toolsrc/include/vcpkg_Strings.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'toolsrc/include') 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; -- cgit v1.2.3 From 3ecc67784aa9ee44953c743362023015e9a09a56 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 10 Oct 2016 18:12:26 -0700 Subject: Add Stopwatch class --- toolsrc/include/Stopwatch.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 toolsrc/include/Stopwatch.h (limited to 'toolsrc/include') 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 +#include + +namespace vcpkg +{ + class Stopwatch + { + public: + static Stopwatch createUnstarted(); + + static Stopwatch createStarted(); + + bool isRunning() const; + + Stopwatch& start(); + + Stopwatch& stop(); + + Stopwatch& reset(); + + template + TimeUnit elapsed() const + { + return std::chrono::duration_cast(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; + }; +} -- cgit v1.2.3 From 38bf4de0fe4772f9aa7c9b5884617369638ba0d8 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 10 Oct 2016 18:46:40 -0700 Subject: Rename System::Stopwatch to System::Stopwatch2 --- toolsrc/include/vcpkg_System.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/include') 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; -- cgit v1.2.3