#include <BLTime.hh>
Entire class could be inline, but is not to prevent bad optimization.
NOTE: On Windows the resolution of timems() and timeus() is only a second! On Mac OS X and on Linux they have the corresponding resolutions.
Static Public Member Functions | |
static long | time () |
time() returns time in seconds since epoch (1970) | |
static long | timems () |
timems() returns the time in milliseconds since epoch (1970) | |
static long long | timeus () |
timeus() returns the time in microseconds since epoch (1970) | |
static void | sleepms (int ms) |
sleepms() will sleep for a specified number of milliseconds. |
long BLTime::time | ( | ) | [static] |
time() returns time in seconds since epoch (1970)
Referenced by BLCMDcollective::beginCollectiveTracking(), BLManager::BeginOfEventAction(), BLManager::BeginOfRunAction(), BLCMDcollective::BLCMDcollective(), BLCMDdemo::command(), BLCMDcollective::endCollectiveTracking(), BLManager::EndOfRunAction(), BLCoil::generateFieldMap(), BLManager::incrEventsProcessed(), BLAlarm::set(), BLAlarm::timeRemaining(), and BLManager::UserSteppingAction().
long BLTime::timems | ( | ) | [static] |
timems() returns the time in milliseconds since epoch (1970)
Referenced by BLCMDcollective::beginCollectiveTracking(), BLCMDcollective::BLCMDcollective(), BLCMDcollective::collectiveStep(), main(), and BLBeam::setRandomSeedToGenerate().
00023 { 00024 #ifndef WIN32 00025 struct timeval tv; 00026 gettimeofday(&tv,0); 00027 return tv.tv_sec*1000+tv.tv_usec/1000; 00028 #else 00029 /*** 00030 struct _timeb timebuffer; 00031 _ftime( &timebuffer ); 00032 return timebuffer.time*1000 + timebuffer.millitm; 00033 ***/ 00034 return ::time(0)*1000; 00035 #endif 00036 }
long long BLTime::timeus | ( | ) | [static] |
timeus() returns the time in microseconds since epoch (1970)
Referenced by BLRealTimeMonitor::estimateResolution1(), BLRealTimeMonitor::getTime(), and BLRealTimeMonitor::setState().
00038 { 00039 #ifndef WIN32 00040 struct timeval tv; 00041 gettimeofday(&tv,0); 00042 return tv.tv_sec*1000000LL+tv.tv_usec; 00043 #else 00044 /*** 00045 struct _timeb timebuffer; 00046 _ftime( &timebuffer ); 00047 return timebuffer.time*1000000LL + timebuffer.millitm*1000LL; 00048 ***/ 00049 return ::time(0)*1000000LL; 00050 #endif 00051 }
void BLTime::sleepms | ( | int | ms | ) | [static] |