Inviwo
0.9.10.1
Inviwo documentation
|
#include <clockgl.h>
Classes | |
struct | Query |
Public Types | |
using | duration = std::chrono::nanoseconds |
Public Member Functions | |
ClockGL () | |
ClockGL (const ClockGL &)=delete | |
ClockGL (ClockGL &&)=default | |
ClockGL & | operator= (const ClockGL &)=delete |
ClockGL & | operator= (ClockGL &&)=default |
bool | isRunning () const |
void | start () |
void | stop () |
void | reset () |
size_t | getCount () const |
duration | getElapsedTime (std::chrono::seconds timeout=std::chrono::seconds{30}) |
duration | getAverageElapsedTime (std::chrono::seconds timeout=std::chrono::seconds{30}) |
double | getElapsedMilliseconds (std::chrono::seconds timeout=std::chrono::seconds{30}) |
double | getElapsedSeconds (std::chrono::seconds timeout=std::chrono::seconds{30}) |
Protected Types | |
enum | State { Unused, Started, Stopped } |
Protected Member Functions | |
void | collectTiming () |
Protected Attributes | |
duration | accumulatedTime_ = static_cast<duration>(0) |
size_t | count_ = 0 |
std::vector< Query > | queries_ |
Clock for measuring elapsed time between a start and stop points on the GPU using OpenGL performance timer queries. The clock accumulates the elapsed times when start and stop are called multiple times.
Note: The render context of the current thread needs to be activated. Using the same ClockGL instance in different render contexts results in undefined behavior and getElapsedTime() will most likely time out.
inviwo::ClockGL::ClockGL | ( | ) |
creates a clock and starts it
auto inviwo::ClockGL::getAverageElapsedTime | ( | std::chrono::seconds | timeout = std::chrono::seconds{30} | ) |
returns the accumulated time divided by count. If the clock is running the result is accumulated time plus the current elapsed time divided by count. This function will wait at most timeout
seconds for the performance queries to be completed. In case of a time out, the results are incorrect.
timeout | time out in seconds when querying the OpenGL performance counters |
size_t inviwo::ClockGL::getCount | ( | ) | const |
return the number of times start has been called. Useful for calculating averages.
double inviwo::ClockGL::getElapsedMilliseconds | ( | std::chrono::seconds | timeout = std::chrono::seconds{30} | ) |
returns the accumulated time. If the clock is running the result is accumulated time plus the current elapsed time. This function will wait at most timeout
seconds for the performance queries to be completed. In case of a time out, the results are incorrect.
timeout | time out in seconds when querying the OpenGL performance counters |
double inviwo::ClockGL::getElapsedSeconds | ( | std::chrono::seconds | timeout = std::chrono::seconds{30} | ) |
returns the accumulated time. If the clock is running the result is accumulated time plus the current elapsed time. This function will wait at most timeout
seconds for the performance queries to be completed. In case of a time out, the results are incorrect.
timeout | time out in seconds when querying the OpenGL performance counters |
auto inviwo::ClockGL::getElapsedTime | ( | std::chrono::seconds | timeout = std::chrono::seconds{30} | ) |
returns the accumulated time. If the clock is running the result is accumulated time plus the current elapsed time. This function will wait at most timeout
seconds for the performance queries to be completed. In case of a time out, the results are incorrect.
timeout | time out in seconds when querying the OpenGL performance counters |
bool inviwo::ClockGL::isRunning | ( | ) | const |
query whether the clock has been started
void inviwo::ClockGL::reset | ( | ) |
resets the queries and sets the accumulated time and count to 0
void inviwo::ClockGL::start | ( | ) |
starts the clock
void inviwo::ClockGL::stop | ( | ) |
stops the clock and accumulates the elapsed time since start() was called