#ifndef CLOCK_H
#define CLOCK_H

#include "data/Array.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<Nanos, LENGTH> time;

public:
    Clock();
    Nanos update();
    float getUpdatesPerSecond() const;
    void wait(Nanos nanos) const;

private:
    Nanos getNanos() const;
};

#endif