mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 21:27:56 -05:00
35 lines
590 B
C++
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 */
|