Inviwo  0.9.10.1
Inviwo documentation
inviwo::ClockGL Class Reference

#include <clockgl.h>

Classes

struct  Query
 

Public Types

using duration = std::chrono::nanoseconds
 

Public Member Functions

 ClockGL ()
 
 ClockGL (const ClockGL &)=delete
 
 ClockGL (ClockGL &&)=default
 
ClockGLoperator= (const ClockGL &)=delete
 
ClockGLoperator= (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< Queryqueries_
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ClockGL()

inviwo::ClockGL::ClockGL ( )

creates a clock and starts it

Member Function Documentation

◆ getAverageElapsedTime()

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.

Parameters
timeouttime 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
timeouttime 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
timeouttime out in seconds when querying the OpenGL performance counters
Returns
accumulated time in seconds
See also
getElapsedTime

◆ getElapsedTime()

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.

Parameters
timeouttime 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 ( )

starts the clock

◆ 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 files: