2015-04-16 16:55:32 +00:00
|
|
|
#ifndef B3_CLOCK_H
|
|
|
|
#define B3_CLOCK_H
|
|
|
|
|
|
|
|
///The b3Clock is a portable basic clock that measures accurate time in seconds, use for profiling.
|
|
|
|
class b3Clock
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
b3Clock();
|
|
|
|
|
|
|
|
b3Clock(const b3Clock& other);
|
|
|
|
b3Clock& operator=(const b3Clock& other);
|
|
|
|
|
|
|
|
~b3Clock();
|
|
|
|
|
2017-06-02 15:18:17 +00:00
|
|
|
/// Resets the initial reference time. If zeroReference is true, will set reference to absolute 0.
|
2018-09-23 21:17:31 +00:00
|
|
|
void reset(bool zeroReference = false);
|
2015-04-16 16:55:32 +00:00
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
/// Returns the time in ms since the last call to reset or since
|
2015-04-16 16:55:32 +00:00
|
|
|
/// the b3Clock was created.
|
|
|
|
unsigned long int getTimeMilliseconds();
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
/// Returns the time in us since the last call to reset or since
|
2015-04-16 16:55:32 +00:00
|
|
|
/// the Clock was created.
|
2016-07-09 22:09:09 +00:00
|
|
|
unsigned long long int getTimeMicroseconds();
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
/// Returns the time in seconds since the last call to reset or since
|
2016-07-09 22:09:09 +00:00
|
|
|
/// the Clock was created.
|
|
|
|
double getTimeInSeconds();
|
|
|
|
|
2016-08-13 19:21:18 +00:00
|
|
|
///Sleep for 'microSeconds', to yield to other threads and not waste 100% CPU cycles.
|
|
|
|
///Note that some operating systems may sleep a longer time.
|
|
|
|
static void usleep(int microSeconds);
|
|
|
|
|
2015-04-16 16:55:32 +00:00
|
|
|
private:
|
|
|
|
struct b3ClockData* m_data;
|
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
#endif //B3_CLOCK_H
|