#include <sys/time.h>
#include <unistd.h>

#define M_SEC 1000 /* Number of milliseconds in a second */

class Timer {
 private:
  int frame_len;
  struct timeval ltotv(unsigned long t);
  unsigned long tvtol(struct timeval t) {
    return (unsigned long)M_SEC * t.tv_sec + t.tv_usec/1000L;
  }
 public:
  int fps;
  Timer(int f);
  int delay(unsigned long i);
  int delay(void);
  unsigned long gettime(void);
};
