00001 // BLTime.hh - system-independent time from epoch 00002 00003 #ifndef BLTIME_HH 00004 #define BLTIME_HH 00005 00006 /** BLTime - get time since epoch. 00007 * 00008 * Entire class could be inline, but is not to prevent bad optimization. 00009 * 00010 * NOTE: On Windows the resolution of timems() and timeus() is only 00011 * a second! On Mac OS X and on Linux they have the corresponding 00012 * resolutions. 00013 **/ 00014 class BLTime { 00015 public: 00016 /// time() returns time in seconds since epoch (1970) 00017 static long time(); 00018 00019 /// timems() returns the time in milliseconds since epoch (1970) 00020 static long timems(); 00021 00022 /// timeus() returns the time in microseconds since epoch (1970) 00023 static long long timeus(); 00024 00025 /// sleepms() will sleep for a specified number of milliseconds. 00026 static void sleepms(int ms); 00027 }; 00028 00029 #endif // BLTIME_HH