123456789101112131415161718192021222324252627282930313233343536373839 |
- #include "client/engine/Clock.h"
- 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)];
- }
|