#ifndef ETIMER_H
#define ETIMER_H

#include "eutils.h"
#include "estr.h"

#ifndef _MSC_VER
 #include <sys/time.h>
#endif

#ifdef _WIN32
 #include <windows.h>
#endif

#undef check

#include <stack>
#include "estrhashof.h"


class eprofiler
{
 public:
#ifdef _WIN32
  std::stack<_LARGE_INTEGER> tstamps;
#else
  std::stack<timeval> tstamps;
#endif

  estr name;
  edoublearray acc;
  elongarray count;
  long tcount;

  eprofiler(const estr& name);
  ~eprofiler();

  void reset();
  void start();
  void stop();
};

eprofiler& getProfiler(const estr& name);

class eprofile
{
 public:
  eprofiler& p;
  eprofile(const estr& p);
  eprofile(eprofiler& p);
  ~eprofile();
};

class etimer
{
 private:
#ifdef _WIN32
  double pifrq;
  _LARGE_INTEGER counter;
#else
  timeval counter;
#endif
 public:
  etimer();

  void reset();
  double check();
  double lap();
};


long egettimestamp();

#endif

