12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "Clock.h"
- #include <iostream>
- Clock::Clock()
- {
- for(int i = 0; i < SIZE; i++)
- {
- time[i] = 0;
- }
- }
- Clock::Clock(const Clock& orig)
- {
- }
- Clock::~Clock()
- {
- }
- void Clock::update()
- {
- uint64_t t = glfwGetTimerValue();
- time[index] = t - oldTime;
- oldTime = t;
-
- sum += time[index];
- index = (index + 1) & (SIZE - 1);
- sum -= time[index];
- }
- double Clock::getUpdatesPerSecond() const
- {
- return (1000000000.0 * (SIZE - 1)) / sum;
- }
- uint64_t Clock::getCurrentTime() const
- {
- return time[(index - 1) & (SIZE - 1)];
- }
|