10 #ifndef NANOVDB_CPU_TIMER_H_HAS_BEEN_INCLUDED 11 #define NANOVDB_CPU_TIMER_H_HAS_BEEN_INCLUDED 18 template <
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;
39 os <<
" microseconds" << std::endl;
41 os <<
" milliseconds" << std::endl;
43 os <<
" seconds" << std::endl;
45 os <<
" unknown time unit" << std::endl;
52 #endif // NANOVDB_CPU_TIMER_HAS_BEEN_INCLUDED void start(const std::string &msg, std::ostream &os=std::cerr)
Definition: CpuTimer.h:24
Definition: NanoVDB.h:184
CpuTimer()
Definition: CpuTimer.h:23
ValueT value
Definition: GridBuilder.h:1287
Definition: CpuTimer.h:19
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