JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
JKQTPHighResTimer Class Reference

This class implements a high resolution timer capable of measuring time intervals with a resolution of some microseconds. More...

#include <jkqtphighrestimer.h>

Public Member Functions

 JKQTPHighResTimer ()
 class constructor.
 
 ~JKQTPHighResTimer ()
 class destructor
 
double getTime ()
 get the time since the last call of start() in microseconds
 
void start ()
 start the timer
 

Protected Attributes

double freq
 internal: timer frequency
 
std::chrono::system_clock::time_point last
 

Detailed Description

This class implements a high resolution timer capable of measuring time intervals with a resolution of some microseconds.

Attention
Note that this is a MS Windows specific implementation od a high-resolution timer using some of windows' API methods (namely QueryPerformanceCounter() and QueryPerformanceFrequency() ). So if you want to use this class on non-win32 systems you will have to find a way to implement it for your system!!!
Also note that a standard windows system is NOT a real time OS. So do not expect to get a high accuracy when timing operations using this timer. It gives you an accurate time stamp, but it can not guarantee when the code is executed!

The timer works very simple:

  • you can start the timer with start() which means you set a time=0
  • then you can query the time difference to the last call of start() by using getTime().
win32 implementation issues:
To implement this timer on windows systems I use two API calls from the windows kernel. They are:
The first one is used to read times: In the start() method we simply save the current counter value to a variable. In getTime() we can then again use QueryPerformanceCounter() to get the current counter value and then calculate the difference between these two. Using QueryPerformanceFrequency() we can calculate the time difference in usecs from the counter value difference using:

\[ \Delta t=\frac{N_{\mbox{now}}-N_{\mbox{start}}}{\mbox{\texttt{QueryPerformanceFrequency()}}}\cdot 10^{6} \]

Constructor & Destructor Documentation

◆ JKQTPHighResTimer()

JKQTPHighResTimer::JKQTPHighResTimer ( )

class constructor.

◆ ~JKQTPHighResTimer()

JKQTPHighResTimer::~JKQTPHighResTimer ( )

class destructor

Member Function Documentation

◆ getTime()

double JKQTPHighResTimer::getTime ( )

get the time since the last call of start() in microseconds

◆ start()

void JKQTPHighResTimer::start ( )

start the timer

Member Data Documentation

◆ freq

double JKQTPHighResTimer::freq
protected

internal: timer frequency

◆ last

std::chrono::system_clock::time_point JKQTPHighResTimer::last
protected

The documentation for this class was generated from the following file: