Files
textmate/Shared/include/oak/duration.h
Allan Odgaard 9894969e67 Initial commit
2012-08-09 16:25:56 +02:00

35 lines
590 B
C++

#ifndef OAK_DURATION_H_NQISZ9T7
#define OAK_DURATION_H_NQISZ9T7
namespace oak
{
struct duration_t
{
duration_t ()
{
reset();
}
void reset ()
{
struct timeval now;
gettimeofday(&now, NULL);
start_time = (double)now.tv_sec + (double)now.tv_usec / 1000000.0;
}
double duration () const
{
struct timeval now;
gettimeofday(&now, NULL);
double elapsed = (double)now.tv_sec + (double)now.tv_usec / 1000000.0;
return elapsed - start_time;
}
private:
double start_time;
};
} /* oak */
#endif /* end of include guard: OAK_DURATION_H_NQISZ9T7 */