#pragma once
-#include <boost/chrono/system_clocks.hpp>
+#include <chrono>
namespace caspar {
// Replacement of boost::timer because it uses std::clock which has very low resolution in linux.
class timer
{
- boost::int_least64_t _start_time;
+ std::chrono::high_resolution_clock::time_point _start_time;
public:
timer()
{
- _start_time = now();
+ _start_time = std::chrono::high_resolution_clock::now();
}
void restart()
{
- _start_time = now();
+ _start_time = std::chrono::high_resolution_clock::now();
}
double elapsed() const
{
- return static_cast<double>(now() - _start_time) / 1000.0;
+ return std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - _start_time).count();
}
private:
- static boost::int_least64_t now()
- {
- using namespace boost::chrono;
-
- return duration_cast<milliseconds>(high_resolution_clock::now().time_since_epoch()).count();
- }
};
}