Zepha/src/util/Timer.h

31 lines
475 B
C
Raw Normal View History

#pragma once
2018-12-02 18:19:37 -08:00
#include <chrono>
#include "util/Types.h"
/**
* Tracks time at nanosecond precision, and provides methods to print
* and retrieve the elapsed time since initialization.
*/
2018-12-02 18:19:37 -08:00
class Timer {
public:
2020-11-08 22:57:34 -08:00
explicit Timer();
explicit Timer(const std::string& name);
u64 elapsedNs() const;
2020-11-08 22:57:34 -08:00
void printElapsedNs();
void printElapsedMs();
void printElapsedSeconds();
private:
string name = "";
2020-11-08 22:57:34 -08:00
std::chrono::high_resolution_clock::time_point start;
2018-12-02 18:19:37 -08:00
};