#include <abktimer.h>
Collaboration diagram for Timer:
Public Member Functions | |
Timer (double limitInSec=0.0) | |
~Timer () | |
void | start (double limitInSec=0.0) |
void | stop () |
void | split () |
void | resume () |
bool | isStopped () const |
double | getUserTime () const |
double | getSysTime () const |
double | getCombTime () const |
double | getRealTime () const |
double | getUnixTime () const |
real time in seconds | |
bool | expired () |
bool | realTimeExpired () |
Protected Types | |
enum | { TIMER_ON, TIMER_OFF, TIMER_SPLIT } |
Protected Attributes | |
enum Timer:: { ... } | status |
Private Member Functions | |
double | getRealTimeOnTheFly () |
double | getUserTimeOnTheFly () |
double | getCombTimeOnTheFly () |
Private Attributes | |
time_t | realTime1 |
time_t | realTime2 |
double | UserTime1 |
double | UserTime2 |
double | timeLimit |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Timer &tm) |
Definition at line 94 of file abktimer.h.
|
Definition at line 128 of file abktimer.h.
00128 {TIMER_ON, TIMER_OFF, TIMER_SPLIT } status; |
|
Definition at line 193 of file abktimer.cxx. References start(), status, and TIMER_OFF.
|
Here is the call graph for this function:
|
Definition at line 133 of file abktimer.h.
00133 { }; |
|
Definition at line 205 of file abktimer.h. References getCombTimeOnTheFly(), and timeLimit.
00206 { 00207 return (timeLimit<getCombTimeOnTheFly()) && (timeLimit!=0.0); 00208 } |
Here is the call graph for this function:
|
Definition at line 291 of file abktimer.cxx. References abkfatal, status, TIMER_OFF, TIMER_SPLIT, UserTime1, and UserTime2.
00292 { 00293 abkfatal(status == TIMER_OFF || status==TIMER_SPLIT, 00294 "Have to stop timer to get a reading\n"); 00295 #if defined(sun) || defined(linux) 00296 return (UserTime2-UserTime1)+(SysTime2-SysTime1); 00297 #elif defined(WIN32) 00298 return 00299 ( (_winTimes->getUserTime2() - _winTimes->getUserTime1()) + 00300 (_winTimes->getKerTime2() - _winTimes->getKerTime1()) ) 00301 *1.0e-7; 00302 #else 00303 return ((UserTime2-UserTime1+0.0)/CLOCKS_PER_SEC); 00304 #endif 00305 } |
|
Definition at line 193 of file abktimer.h. References abkfatal, getUserTimeOnTheFly(), and UserTime1. Referenced by expired().
00194 { 00195 #if defined(sun) || defined(linux) 00196 abkfatal(getrusage(RUSAGE_SELF,&_ru)!=-1,"Can't get time"); 00197 return _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec - UserTime1 00198 +_ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec - SysTime1; 00199 #else 00200 return getUserTimeOnTheFly(); 00201 #endif 00202 } |
Here is the call graph for this function:
|
Definition at line 307 of file abktimer.cxx. References abkfatal, realTime1, realTime2, status, TIMER_OFF, and TIMER_SPLIT. Referenced by getUserTime(), operator<<(), and BaseAnnealer::printResults().
00308 { 00309 abkfatal(status == TIMER_OFF || status==TIMER_SPLIT, 00310 "Have to stop timer to get a reading\n"); 00311 #ifdef WIN32 00312 return (_winTimes->getRealTime2()-_winTimes->getRealTime1())/ 00313 _winTimes->getFreq(); 00314 #else 00315 return difftime(realTime2,realTime1); 00316 #endif 00317 } |
|
Definition at line 169 of file abktimer.h. References realTime1, and realTime2. Referenced by realTimeExpired().
00170 {
00171 time(&realTime2);
00172 return difftime(realTime2,realTime1);
00173 }
|
|
Definition at line 278 of file abktimer.cxx. References abkfatal, status, TIMER_OFF, and TIMER_SPLIT. Referenced by operator<<().
00279 { 00280 abkfatal(status == TIMER_OFF || status==TIMER_SPLIT, 00281 "Have to stop timer to get a reading\n"); 00282 #if defined(sun) || defined(linux) 00283 return (SysTime2-SysTime1); 00284 #elif defined(WIN32) 00285 return (_winTimes->getKerTime2() - _winTimes->getKerTime1())*1.0e-7; 00286 #else 00287 return 0; 00288 #endif 00289 } |
|
real time in seconds
Definition at line 319 of file abktimer.cxx. References abkfatal. Referenced by SeedHandler::_chooseInitNondetSeed().
00320 { 00321 time_t utime, zero=0; 00322 abkfatal(time(&utime)!=-1,"Can't get time\n"); 00323 return difftime(utime, zero); 00324 } |
|
Definition at line 262 of file abktimer.cxx. References abkfatal, getRealTime(), status, TIMER_OFF, TIMER_SPLIT, UserTime1, and UserTime2. Referenced by BTreeAreaWireAnnealer::anneal(), parquetfp::Annealer::anneal(), parquetfp::SolveMulti::clusterOnly(), DebugBTreeAnnealerFromDB(), parquetfp::SolveMulti::go(), Parquet::go(), BTreeAreaWireAnnealer::go(), parquetfp::Annealer::go(), main(), operator<<(), BaseAnnealer::printResults(), and CPUNormalizer::update().
00263 { 00264 abkfatal(status == TIMER_OFF || status==TIMER_SPLIT, 00265 "Have to stop timer to get a reading\n"); 00266 #if defined(sun) || defined(linux) 00267 return (UserTime2-UserTime1); 00268 #elif defined(WIN32) 00269 return (_winTimes->getUserTime2() - _winTimes->getUserTime1())*1.0e-7; 00270 #else 00271 if (getRealTime()>(INT_MAX+0.0)/CLOCKS_PER_SEC) 00272 return 0.0; // not to give a suspiciously correct reading 00273 return ((UserTime2-UserTime1+0.0)/CLOCKS_PER_SEC); 00274 #endif 00275 00276 } |
Here is the call graph for this function:
|
Definition at line 175 of file abktimer.h. References abkfatal, and UserTime1. Referenced by getCombTimeOnTheFly().
|
|
Definition at line 141 of file abktimer.h. References status, and TIMER_OFF.
|
|
Definition at line 210 of file abktimer.h. References getRealTimeOnTheFly(), and timeLimit.
00211 { 00212 return (timeLimit<getRealTimeOnTheFly()) && (timeLimit!=0.0); 00213 } |
Here is the call graph for this function:
|
Definition at line 256 of file abktimer.cxx. References abkfatal, status, TIMER_ON, and TIMER_SPLIT.
|
|
Definition at line 250 of file abktimer.cxx. References status, stop(), and TIMER_SPLIT.
00251 { 00252 stop(); 00253 status=TIMER_SPLIT; 00254 } |
Here is the call graph for this function:
|
Definition at line 209 of file abktimer.cxx. References abkfatal, realTime1, status, timeLimit, TIMER_OFF, TIMER_ON, and UserTime1. Referenced by BTreeAreaWireAnnealer::anneal(), parquetfp::Annealer::anneal(), DebugBTreeAnnealerFromDB(), Parquet::go(), BTreeAreaWireAnnealer::go(), parquetfp::Annealer::go(), main(), and Timer().
00210 { 00211 abkfatal(status == TIMER_OFF, "Can't start timer twice"); 00212 status = TIMER_ON; 00213 00214 timeLimit=limitInSec; 00215 00216 #ifndef WIN32 00217 abkfatal(time(&realTime1)!=-1,"Can't get time"); 00218 #endif 00219 #if defined(sun) || defined (linux) 00220 abkfatal(getrusage(RUSAGE_SELF,&_ru)!=-1," Can't get time"); 00221 UserTime1 = _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec; 00222 SysTime1 = _ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec; 00223 #elif defined(WIN32) 00224 _winTimes->doTimes1(); 00225 #else 00226 UserTime1=clock(); 00227 #endif 00228 } |
|
Definition at line 230 of file abktimer.cxx. References abkfatal, realTime2, status, TIMER_OFF, TIMER_ON, and UserTime2. Referenced by BTreeAreaWireAnnealer::anneal(), parquetfp::Annealer::anneal(), parquetfp::SolveMulti::clusterOnly(), DebugBTreeAnnealerFromDB(), parquetfp::SolveMulti::go(), Parquet::go(), BTreeAreaWireAnnealer::go(), parquetfp::Annealer::go(), main(), split(), and CPUNormalizer::update().
00231 { 00232 abkfatal(status == TIMER_ON, "Can't stop timer twice!\n"); 00233 status=TIMER_OFF; 00234 00235 #ifndef WIN32 00236 abkfatal(time(&realTime2)!=-1,"Can't get time\n"); 00237 #endif 00238 00239 #if defined(sun) || defined(linux) 00240 abkfatal(getrusage(RUSAGE_SELF,&_ru)!=-1," Can't get time"); 00241 UserTime2 = _ru.ru_utime.tv_sec+1e-6*_ru.ru_utime.tv_usec; 00242 SysTime2 = _ru.ru_stime.tv_sec+1e-6*_ru.ru_stime.tv_usec; 00243 #elif defined(WIN32) 00244 _winTimes->doTimes2(); 00245 #else 00246 UserTime2=clock(); 00247 #endif 00248 } |
|
Definition at line 326 of file abktimer.cxx.
00327 { 00328 #if defined(sun) || defined(WIN32) || defined(linux) 00329 CPUNormalizer cpunorm; 00330 double userSec=tm.getUserTime(), 00331 normSec=tm.getUserTime() * cpunorm.getNormalizingFactor(); 00332 char buffer[20]; 00333 if (userSec>0.01) 00334 { 00335 double frac =userSec-floor(userSec); 00336 double delta=frac-0.001*floor(frac*1000.0); 00337 userSec-=delta; 00338 frac =normSec-floor(normSec); 00339 delta=frac-0.001*floor(frac*1000); 00340 normSec-=delta; 00341 } 00342 00343 00344 sprintf(buffer,"%.1e",tm.getSysTime()); 00345 00346 os << " " << userSec <<" user," 00347 << " " << buffer <<" system," 00348 << " " << tm.getRealTime() <<" real," 00349 << " " << normSec << " norm'd " 00350 << "sec "; 00351 #else 00352 if (tm.getRealTime()>(INT_MAX+0.0)/CLOCKS_PER_SEC) 00353 os << tm.getRealTime() << " real sec"; 00354 else 00355 os << " " << tm.getUserTime() << " user sec, " 00356 << tm.getRealTime() << " real sec"; 00357 #endif 00358 return os; 00359 } |
|
Definition at line 97 of file abktimer.h. Referenced by getRealTime(), getRealTimeOnTheFly(), and start(). |
|
Definition at line 97 of file abktimer.h. Referenced by getRealTime(), getRealTimeOnTheFly(), and stop(). |
|
Referenced by getCombTime(), getRealTime(), getSysTime(), getUserTime(), isStopped(), resume(), split(), start(), stop(), and Timer(). |
|
Definition at line 103 of file abktimer.h. Referenced by expired(), realTimeExpired(), and start(). |
|
Definition at line 99 of file abktimer.h. Referenced by getCombTime(), getCombTimeOnTheFly(), getUserTime(), getUserTimeOnTheFly(), and start(). |
|
Definition at line 99 of file abktimer.h. Referenced by getCombTime(), getUserTime(), and stop(). |