4 #ifndef OPENVDB_UTIL_CPUTIMER_HAS_BEEN_INCLUDED
5 #define OPENVDB_UTIL_CPUTIMER_HAS_BEEN_INCLUDED
70 CpuTimer(std::ostream& os = std::cerr) : mOutStream(os), mT0(
this->now()) {}
80 inline void start() { mT0 = this->now(); }
87 mOutStream << msg <<
" ...";
96 return (this->now() - mT0);
104 static constexpr
double resolution = 1.0 / 1E3;
105 return static_cast<double>(this->
microseconds()) * resolution;
113 static constexpr
double resolution = 1.0 / 1E6;
114 return static_cast<double>(this->
microseconds()) * resolution;
120 std::ostringstream os;
131 printTime(mOutStream, msec,
" completed in ",
"\n", 4, 3, 1);
141 mOutStream << msg <<
" ...";
142 printTime(mOutStream, msec,
" completed in ",
"\n", 4, 3, 1);
163 const double delta = this->
stop();
174 const auto time_since_epoch =
175 std::chrono::steady_clock::now().time_since_epoch();
178 std::chrono::duration_cast<std::chrono::microseconds>(time_since_epoch).
count();
183 std::ostream& mOutStream;
192 #endif // OPENVDB_UTIL_CPUTIMER_HAS_BEEN_INCLUDED
OPENVDB_API int printTime(std::ostream &os, double milliseconds, const std::string &head="", const std::string &tail="\n", int width=4, int precision=1, int verbose=0)
GLsizei const GLchar *const * string
double milliseconds() const
Return Time difference in milliseconds since construction or start was called.
#define OPENVDB_USE_VERSION_NAMESPACE
double stop(const std::string &msg) const
Returns and prints time in milliseconds since construction or start was called.
**But if you need a or simply need to know when the task has note that the like this
int64_t microseconds() const
Return Time difference in microseconds since construction or start was called.
double seconds() const
Return Time difference in seconds since construction or start was called.
Simple timer for basic profiling.
double restart()
Re-start timer.
HUSD_API const char * resolution()
CpuTimer(const std::string &msg, std::ostream &os=std::cerr)
Prints message and start timer.
CpuTimer(std::ostream &os=std::cerr)
Initiate timer.
Library and file format version numbers.
double stop() const
Returns and prints time in milliseconds since construction or start was called.
double restart(const std::string &msg)
Stop previous timer, print message and re-start timer.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
void start(const std::string &msg)
Print message and start timer.