ccls/src/timer.h

23 lines
513 B
C
Raw Normal View History

2017-03-25 19:18:25 +00:00
#pragma once
#include <chrono>
2017-03-31 04:13:58 +00:00
#include <string>
2017-03-25 19:18:25 +00:00
struct Timer {
using Clock = std::chrono::high_resolution_clock;
// Creates a new timer. A timer is always running.
Timer();
// Restart/reset the timer.
void Reset();
2017-03-31 04:13:58 +00:00
// Resets timer and prints a message like "<foo> took 5ms"
void ResetAndPrint(const std::string& message);
2017-03-25 19:18:25 +00:00
// Return the number of milliseconds since the timer was last reset.
long long ElapsedMilliseconds();
// Raw start time.
std::chrono::time_point<Clock> start;
};