Clock.cppm 479 B

12345678910111213141516171819202122232425
  1. module;
  2. export module Core.Clock;
  3. import Core.Array;
  4. export namespace Core {
  5. struct Clock final {
  6. size_t index;
  7. i64 last;
  8. i64 sum;
  9. Array<i64, 1 << 7> time;
  10. public:
  11. Clock();
  12. // the first invocation will always return 0 nanos
  13. i64 update();
  14. float getUpdatesPerSecond() const;
  15. static bool sleepNanos(i64 nanos);
  16. static bool sleepMillis(i64 millis);
  17. static i64 getNanos();
  18. };
  19. }