mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-17 20:27:50 +08:00
32 lines
681 B
C++
32 lines
681 B
C++
#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;
|
|
};
|
|
}
|