ccls/src/timer.cc

22 lines
454 B
C++
Raw Normal View History

2017-03-25 19:18:25 +00:00
#include "timer.h"
2017-03-31 04:13:58 +00:00
#include <iostream>
2017-03-25 19:18:25 +00:00
Timer::Timer() {
Reset();
}
void Timer::Reset() {
start = Clock::now();
}
2017-03-31 04:13:58 +00:00
void Timer::ResetAndPrint(const std::string& message) {
std::cerr << message << " took " << ElapsedMilliseconds() << "ms" << std::endl;
Reset();
}
2017-03-25 19:18:25 +00:00
long long Timer::ElapsedMilliseconds() {
std::chrono::time_point<Clock> end = Clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
}