Clock.cppm 470 B

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