Aktualizr
C++ SOTA Client
timer.cc
1 #include "timer.h"
2 #include <iomanip>
3 
4 Timer::Timer() : start_(Timer::Clock::now()) {}
5 
6 bool Timer::RunningMoreThan(double seconds) const {
7  return start_ + std::chrono::duration<double>(seconds) < Timer::Clock::now();
8 }
9 
10 std::ostream& operator<<(std::ostream& os, const Timer& timer) {
11  Timer::Clock::duration elapsed = Timer::Clock::now() - timer.start_;
12  std::chrono::duration<double> sec = elapsed;
13  os << std::setprecision(3) << sec.count() << "s";
14  return os;
15 }
Elapsed time measurement.
Definition: timer.h:10