#include <clockgl.h>
|
using | duration = std::chrono::nanoseconds |
|
|
enum class | State { Unused
, Started
, Stopped
} |
|
|
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.
- See also
- RenderContext::activateDefaultRenderContext, RenderContext::activateLocalRenderContext
◆ ClockGL()
inviwo::ClockGL::ClockGL |
( |
| ) |
|
creates a clock and starts it
◆ getAverageElapsedTime()
duration 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.
- Parameters
-
timeout | time out in seconds when querying the OpenGL performance counters |
- Returns
- accumulated time
◆ getCount()
size_t inviwo::ClockGL::getCount |
( |
| ) |
const |
return the number of times start has been called. Useful for calculating averages.
◆ getElapsedMilliseconds()
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.
- Parameters
-
timeout | time out in seconds when querying the OpenGL performance counters |
- Returns
- accumulated time in milliseconds
- See also
- getElapsedTime
◆ getElapsedSeconds()
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.
- Parameters
-
timeout | time out in seconds when querying the OpenGL performance counters |
- Returns
- accumulated time in seconds
- See also
- getElapsedTime
◆ getElapsedTime()
duration 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.
- Parameters
-
timeout | time out in seconds when querying the OpenGL performance counters |
- Returns
- accumulated time
◆ isRunning()
bool inviwo::ClockGL::isRunning |
( |
| ) |
const |
query whether the clock has been started
- Returns
- true if the clock is running
◆ reset()
void inviwo::ClockGL::reset |
( |
| ) |
|
resets the queries and sets the accumulated time and count to 0
◆ start()
void inviwo::ClockGL::start |
( |
| ) |
|
◆ stop()
void inviwo::ClockGL::stop |
( |
| ) |
|
stops the clock and accumulates the elapsed time since start() was called
The documentation for this class was generated from the following file: