10#ifndef NANOVDB_CPU_TIMER_H_HAS_BEEN_INCLUDED
11#define NANOVDB_CPU_TIMER_H_HAS_BEEN_INCLUDED
18template <
typename Accuracy = std::chrono::milliseconds>
21 std::chrono::high_resolution_clock::time_point mStart;
24 void start(
const std::string &msg, std::ostream& os = std::cerr) {
25 os << msg <<
" ... " << std::flush;
26 mStart = std::chrono::high_resolution_clock::now();
28 void restart(
const std::string &msg, std::ostream& os = std::cerr) {
30 os << msg <<
" ... " << std::flush;
31 mStart = std::chrono::high_resolution_clock::now();
33 void stop(std::ostream& os = std::cerr)
35 auto end = std::chrono::high_resolution_clock::now();
36 auto diff = std::chrono::duration_cast<Accuracy>(end - mStart).count();
37 os <<
"completed in " << diff;
38 if (std::is_same<Accuracy, std::chrono::microseconds>::value) {
39 os <<
" microseconds" << std::endl;
40 }
else if (std::is_same<Accuracy, std::chrono::milliseconds>::value) {
41 os <<
" milliseconds" << std::endl;
42 }
else if (std::is_same<Accuracy, std::chrono::seconds>::value) {
43 os <<
" seconds" << std::endl;
45 os <<
" unknown time unit" << std::endl;
Definition: CpuTimer.h:20
CpuTimer()
Definition: CpuTimer.h:23
void restart(const std::string &msg, std::ostream &os=std::cerr)
Definition: CpuTimer.h:28
void stop(std::ostream &os=std::cerr)
Definition: CpuTimer.h:33
void start(const std::string &msg, std::ostream &os=std::cerr)
Definition: CpuTimer.h:24
Definition: NanoVDB.h:208