diff options
author | Peter Baumann <p.baumann@jacobs-university.de> | 2010-07-27 08:59:55 +0200 |
---|---|---|
committer | www-data <www-data@ubuntu.localdomain> | 2010-07-30 11:08:03 +0200 |
commit | 437ff942525f86a36655519cea0f5a03da319cd7 (patch) | |
tree | e8b29697ca4561311fbec58d5f71f7ee521c2533 /raslib/rmdebug.icc | |
parent | 18b61341d3c0f597ef71af2dc33769277defe9d5 (diff) | |
download | rasdaman-upstream-437ff942525f86a36655519cea0f5a03da319cd7.tar.gz rasdaman-upstream-437ff942525f86a36655519cea0f5a03da319cd7.tar.xz rasdaman-upstream-437ff942525f86a36655519cea0f5a03da319cd7.zip |
PB: improved benchmark output
Diffstat (limited to 'raslib/rmdebug.icc')
-rw-r--r-- | raslib/rmdebug.icc | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/raslib/rmdebug.icc b/raslib/rmdebug.icc index f325c10..91bea8d 100644 --- a/raslib/rmdebug.icc +++ b/raslib/rmdebug.icc @@ -64,30 +64,12 @@ RMTimer::pause() { if( running ) { + fetchTime(); #ifdef __VISUALC__ - // save start time - oldsec = acttime; - oldusec = 0; // Windows only counts the seconds (too slow??!!) - - // get stop time - time(&acttime); - - // add new time to accu - accuTime += (acttime-oldsec)*1000000; -#else - // save start time - oldsec = acttime.tv_sec; - oldusec = acttime.tv_usec; - - // get stop time - gettimeofday(&acttime, &dummy); - - // add new time to accu - accuTime += (acttime.tv_sec-oldsec)*1000000 + acttime.tv_usec - oldusec; - // reset acttime.tv_usec which means that no timer is running acttime.tv_usec = 0; #endif + // timer is not running running = 0; } @@ -112,10 +94,46 @@ RMTimer::stop() pause(); if(output && RManBenchmark >= bmLevel ) { - RMInit::bmOut << std::endl - << "PerformanceTimer: " << myClass << " :: " << myFunc << ": " - << accuTime << " usecs" << std::endl; + RMInit::bmOut + << std::endl + << "PerformanceTimer: " << myClass << " :: " << myFunc << " = " + << accuTime << " usecs" << std::endl; // set output to FALSE output = 0; } } + +inline int +RMTimer::getTime() +{ + fetchTime(); + return accuTime; +} + +inline void +RMTimer::fetchTime() +{ +#ifdef __VISUALC__ + // save start time + oldsec = acttime; + oldusec = 0; // Windows only counts the seconds (too slow??!!) + + // get stop time + time(&acttime); + + // add new time to accu + accuTime += (acttime-oldsec)*1000000; +#else + // save start time + oldsec = acttime.tv_sec; + oldusec = acttime.tv_usec; + + // get stop time + gettimeofday(&acttime, &dummy); + + // add new time to accu + accuTime += (acttime.tv_sec-oldsec)*1000000 + acttime.tv_usec - oldusec; + +#endif +} + |