10 #ifndef NANOVDB_CPU_TIMER_H_HAS_BEEN_INCLUDED
11 #define NANOVDB_CPU_TIMER_H_HAS_BEEN_INCLUDED
20 std::chrono::high_resolution_clock::time_point mStart;
35 os << msg <<
" ... " << std::flush;
36 mStart = std::chrono::high_resolution_clock::now();
40 template <
typename AccuracyT = std::chrono::milliseconds>
43 auto end = std::chrono::high_resolution_clock::now();
44 return std::chrono::duration_cast<AccuracyT>(
end - mStart).
count();
50 template <
typename AccuracyT = std::chrono::milliseconds>
51 void stop(std::ostream& os = std::cerr)
53 auto end = std::chrono::high_resolution_clock::now();
54 auto diff = std::chrono::duration_cast<AccuracyT>(
end - mStart).
count();
55 os <<
"completed in " << diff;
57 os <<
" microseconds" << std::endl;
59 os <<
" milliseconds" << std::endl;
61 os <<
" seconds" << std::endl;
63 os <<
" unknown time unit" << std::endl;
71 template <
typename AccuracyT = std::chrono::milliseconds>
74 this->stop<AccuracyT>();
83 #endif // NANOVDB_CPU_TIMER_HAS_BEEN_INCLUDED
void start(const std::string &msg, std::ostream &os=std::cerr)
Start the timer.
void restart(const std::string &msg, std::ostream &os=std::cerr)
stop and start the timer
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
auto elapsed()
elapsed time (since start) in miliseconds
CpuTimer(const std::string &msg, std::ostream &os=std::cerr)
Constructor that starts the timer.
void stop(std::ostream &os=std::cerr)
stop the timer
CpuTimer()
Default constructor.