4 #include <sys/resource.h>
19 Returns the current timestamp.
26 return TimeStamp(tv.tv_sec*1000000LL+tv.tv_usec);
28 static RawTime epoch = 0;
41 SystemTimeToFileTime(&st, &ft);
42 epoch = (ft.dwLowDateTime+(static_cast<RawTime>(ft.dwHighDateTime)<<32))/10;
46 GetSystemTimeAsFileTime(&ft);
47 return TimeStamp((ft.dwLowDateTime+(static_cast<RawTime>(ft.dwHighDateTime)<<32))/10-epoch);
51 string format_now(const string &fmt)
53 return DateTime(now()).format(fmt);
57 Returns the CPU time used by the program so far.
59 TimeDelta get_cpu_time()
63 getrusage(RUSAGE_SELF, &ru);
64 return (ru.ru_utime.tv_sec+ru.ru_stime.tv_sec)*sec + (ru.ru_utime.tv_usec+ru.ru_stime.tv_usec)*usec;
66 //XXX Figure out the function to use on Win32
72 Sleeps for the given time.
74 int sleep(const TimeDelta &d)
78 return nanosleep(&ts, 0);
80 Sleep((DWORD)(d/msec));