Simple timer for basic profiling.
More...
#include <openvdb/util/CpuTimer.h>
|
| CpuTimer (std::ostream &os=std::cerr) |
| Initiate timer.
|
|
| CpuTimer (const std::string &msg, std::ostream &os=std::cerr) |
| Prints message and start timer.
|
|
void | start () |
| Start timer.
|
|
void | start (const std::string &msg) |
| Print message and start timer.
|
|
int64_t | microseconds () const |
| Return Time difference in microseconds since construction or start was called.
|
|
double | milliseconds () const |
| Return Time difference in milliseconds since construction or start was called.
|
|
double | seconds () const |
| Return Time difference in seconds since construction or start was called.
|
|
std::string | time () const |
|
double | stop () const |
| Returns and prints time in milliseconds since construction or start was called.
|
|
double | stop (const std::string &msg) const |
| Returns and prints time in milliseconds since construction or start was called.
|
|
double | restart () |
| Re-start timer.
|
|
double | restart (const std::string &msg) |
| Stop previous timer, print message and re-start timer.
|
|
Simple timer for basic profiling.
timer.
start(
"algorithm");
Simple timer for basic profiling.
Definition CpuTimer.h:67
void start()
Start timer.
Definition CpuTimer.h:80
double stop() const
Returns and prints time in milliseconds since construction or start was called.
Definition CpuTimer.h:128
or to time multiple blocks of code
double restart()
Re-start timer.
Definition CpuTimer.h:150
or to measure speedup between multiple runs
const double t1 = timer.
restart(
"algorithm 2");
const double t2 = timer.
stop();
std::cerr << "Algorithm 1 is " << (t2/t1)
<< " timers faster than algorithm 2\n";
or to measure multiple blocks of code with deferred output
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)
◆ CpuTimer() [1/2]
CpuTimer |
( |
std::ostream & | os = std::cerr | ) |
|
|
inline |
◆ CpuTimer() [2/2]
CpuTimer |
( |
const std::string & | msg, |
|
|
std::ostream & | os = std::cerr ) |
|
inline |
Prints message and start timer.
- Note
- Should normally be followed by a call to stop()
◆ microseconds()
int64_t microseconds |
( |
| ) |
const |
|
inline |
Return Time difference in microseconds since construction or start was called.
- Note
- Combine this method with start() to get timing without any outputs.
◆ milliseconds()
double milliseconds |
( |
| ) |
const |
|
inline |
Return Time difference in milliseconds since construction or start was called.
- Note
- Combine this method with start() to get timing without any outputs.
◆ restart() [1/2]
Re-start timer.
- Returns
- time in milliseconds since previous start or restart.
- Note
- Should normally be followed by a call to stop() or restart()
◆ restart() [2/2]
double restart |
( |
const std::string & | msg | ) |
|
|
inline |
Stop previous timer, print message and re-start timer.
- Returns
- time in milliseconds since previous start or restart.
- Note
- Should normally be followed by a call to stop() or restart()
◆ seconds()
Return Time difference in seconds since construction or start was called.
- Note
- Combine this method with start() to get timing without any outputs.
◆ start() [1/2]
Start timer.
- Note
- Should normally be followed by a call to milliseconds() or stop(std::string)
◆ start() [2/2]
void start |
( |
const std::string & | msg | ) |
|
|
inline |
Print message and start timer.
- Note
- Should normally be followed by a call to stop()
◆ stop() [1/2]
Returns and prints time in milliseconds since construction or start was called.
- Note
- Combine this method with start(std::string) to print at start and stop of task being timed.
◆ stop() [2/2]
double stop |
( |
const std::string & | msg | ) |
const |
|
inline |
Returns and prints time in milliseconds since construction or start was called.
- Note
- Combine this method with start() to delay output of task being timed.
◆ time()
std::string time |
( |
| ) |
const |
|
inline |