aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-11-29 23:45:47 -0800
committerRobert Schumacher <roschuma@microsoft.com>2017-11-30 08:09:09 -0800
commitd38d4a75408e0e9d0820187b16da2e06ce0ee316 (patch)
tree87283ec20faca18853b77de41f3825119899ee9c /toolsrc/include
parent6c5f52daf3cf1c3d7c0f8430f62436bf1d298b1b (diff)
downloadvcpkg-d38d4a75408e0e9d0820187b16da2e06ce0ee316.tar.gz
vcpkg-d38d4a75408e0e9d0820187b16da2e06ce0ee316.zip
[vcpkg] Add --x-xunit internal command to print installation results in a VSTS friendly format.
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/chrono.h31
-rw-r--r--toolsrc/include/vcpkg/globalstate.h4
-rw-r--r--toolsrc/include/vcpkg/install.h4
3 files changed, 30 insertions, 9 deletions
diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h
index b525852f2..c791f53fa 100644
--- a/toolsrc/include/vcpkg/base/chrono.h
+++ b/toolsrc/include/vcpkg/base/chrono.h
@@ -7,18 +7,37 @@ namespace vcpkg::Chrono
{
class ElapsedTime
{
- public:
- static ElapsedTime create_started();
+ using duration = std::chrono::high_resolution_clock::time_point::duration;
- constexpr ElapsedTime() : m_start_tick() {}
+ public:
+ constexpr ElapsedTime() : m_duration() {}
+ constexpr ElapsedTime(duration d) : m_duration(d) {}
template<class TimeUnit>
- TimeUnit elapsed() const
+ TimeUnit as() const
+ {
+ return std::chrono::duration_cast<TimeUnit>(m_duration);
+ }
+
+ std::string to_string() const;
+
+ private:
+ std::chrono::high_resolution_clock::time_point::duration m_duration;
+ };
+
+ class ElapsedTimer
+ {
+ public:
+ static ElapsedTimer create_started();
+
+ constexpr ElapsedTimer() : m_start_tick() {}
+
+ ElapsedTime elapsed() const
{
- return std::chrono::duration_cast<TimeUnit>(std::chrono::high_resolution_clock::now() - this->m_start_tick);
+ return ElapsedTime(std::chrono::high_resolution_clock::now() - this->m_start_tick);
}
- double microseconds() const { return elapsed<std::chrono::duration<double, std::micro>>().count(); }
+ double microseconds() const { return elapsed().as<std::chrono::duration<double, std::micro>>().count(); }
std::string to_string() const;
diff --git a/toolsrc/include/vcpkg/globalstate.h b/toolsrc/include/vcpkg/globalstate.h
index 7cea361cf..40ec7958e 100644
--- a/toolsrc/include/vcpkg/globalstate.h
+++ b/toolsrc/include/vcpkg/globalstate.h
@@ -9,11 +9,11 @@ namespace vcpkg
{
struct GlobalState
{
- static Util::LockGuarded<Chrono::ElapsedTime> timer;
+ static Util::LockGuarded<Chrono::ElapsedTimer> timer;
static std::atomic<bool> debugging;
static std::atomic<bool> feature_packages;
static std::atomic<int> g_init_console_cp;
static std::atomic<int> g_init_console_output_cp;
};
-} \ No newline at end of file
+}
diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h
index 28896adee..2e92764dc 100644
--- a/toolsrc/include/vcpkg/install.h
+++ b/toolsrc/include/vcpkg/install.h
@@ -1,5 +1,6 @@
#pragma once
+#include <vcpkg/base/chrono.h>
#include <vcpkg/build.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgcmdarguments.h>
@@ -25,7 +26,7 @@ namespace vcpkg::Install
PackageSpec spec;
Build::ExtendedBuildResult build_result;
- std::string timing;
+ vcpkg::Chrono::ElapsedTime timing;
const Dependencies::AnyAction* action;
};
@@ -36,6 +37,7 @@ namespace vcpkg::Install
std::string total_elapsed_time;
void print() const;
+ std::string xunit_results() const;
};
struct InstallDir