mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 17:41:58 +00:00
22 lines
454 B
C++
22 lines
454 B
C++
#include "timer.h"
|
|
|
|
#include <iostream>
|
|
|
|
Timer::Timer() {
|
|
Reset();
|
|
}
|
|
|
|
void Timer::Reset() {
|
|
start = Clock::now();
|
|
}
|
|
|
|
void Timer::ResetAndPrint(const std::string& message) {
|
|
std::cerr << message << " took " << ElapsedMilliseconds() << "ms" << std::endl;
|
|
Reset();
|
|
}
|
|
|
|
long long Timer::ElapsedMilliseconds() {
|
|
std::chrono::time_point<Clock> end = Clock::now();
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
|
}
|