#ifndef CLOCK_H #define CLOCK_H #include "data/Array.h" #include "utils/Check.h" #include "utils/Error.h" #include "utils/Types.h" struct Clock final { typedef int64 Nanos; private: static constexpr int BITS = 7; static constexpr int LENGTH = 1 << BITS; int index; Nanos last; Nanos sum; Array time; public: Clock(); // the first invocation will always return 0 nanos check_return Error update(Nanos& n); check_return float getUpdatesPerSecond() const; check_return Error wait(Nanos nanos) const; check_return static Error getNanos(Nanos& n); }; #endif