Clock.h 394 B

1234567891011121314151617181920212223
  1. #ifndef CLOCK_H
  2. #define CLOCK_H
  3. #include "common/utils/Types.h"
  4. #include "common/utils/Array.h"
  5. class Clock final {
  6. public:
  7. Clock();
  8. u64 update();
  9. u64 getLength() const;
  10. float getUpdatesPerSecond() const;
  11. private:
  12. static constexpr u64 bits = 7;
  13. static constexpr u64 length = 1 << bits;
  14. u64 last;
  15. u64 index;
  16. s64 sum;
  17. Array<u64, length> time;
  18. };
  19. #endif