10 template <
typename ClockType = std::chrono::steady_clock>
19 explicit constexpr Timer(std::size_t reserveSize = 8) {
25 constexpr std::size_t
size()
const {
43 std::string str = std::format(
"Total record entries: {}\n",
timepoints_.size());
46 auto dur = timepoint -
begin_;
47 str += std::format(
"\t[{}] {}, {}, {}\n",
49 std::chrono::duration_cast<std::chrono::seconds>(dur),
50 std::chrono::duration_cast<std::chrono::milliseconds>(dur),
51 std::chrono::duration_cast<std::chrono::microseconds>(dur));
constexpr std::size_t size() const
Returns the number of recorded time points.
void record()
Records the current time point relative to the last reset.
std::string toString() const
Formats and returns a string showing all recorded durations since reset.
std::vector< TimePoint > timepoints_
void reset()
Clears all recorded time points and resets the starting time.
constexpr Timer(std::size_t reserveSize=8)
Constructs a Timer and reserves space for time points.
typename ClockType::time_point TimePoint