19 #if !defined(__NORI_TIMER_H)
20 #define __NORI_TIMER_H
22 #include <nori/common.h>
38 void reset() { start = std::chrono::system_clock::now(); }
42 auto now = std::chrono::system_clock::now();
43 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
44 return (
double) duration.count();
49 return timeString(
elapsed(), precise);
54 auto now = std::chrono::system_clock::now();
55 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - start);
57 return (
double) duration.count();
62 return timeString(
lap(), precise);
65 std::chrono::system_clock::time_point start;
Simple timer with millisecond precision.
std::string elapsedString(bool precise=false) const
Like elapsed(), but return a human-readable string.
Timer()
Create a new timer and reset it.
double elapsed() const
Return the number of milliseconds elapsed since the timer was last reset.
std::string lapString(bool precise=false)
Like lap(), but return a human-readable string.
void reset()
Reset the timer to the current time.
double lap()
Return the number of milliseconds elapsed since the timer was last reset and then reset it.