summaryrefslogtreecommitdiffstats
path: root/raslib
diff options
context:
space:
mode:
authorPeter Baumann <p.baumann@jacobs-university.de>2010-07-27 08:59:55 +0200
committerwww-data <www-data@ubuntu.localdomain>2010-07-30 11:08:03 +0200
commit437ff942525f86a36655519cea0f5a03da319cd7 (patch)
treee8b29697ca4561311fbec58d5f71f7ee521c2533 /raslib
parent18b61341d3c0f597ef71af2dc33769277defe9d5 (diff)
downloadrasdaman-upstream-437ff942525f86a36655519cea0f5a03da319cd7.tar.gz
rasdaman-upstream-437ff942525f86a36655519cea0f5a03da319cd7.tar.xz
rasdaman-upstream-437ff942525f86a36655519cea0f5a03da319cd7.zip
PB: improved benchmark output
Diffstat (limited to 'raslib')
-rw-r--r--raslib/rmdebug.hh14
-rw-r--r--raslib/rmdebug.icc64
-rw-r--r--raslib/rminit.hh2
3 files changed, 50 insertions, 30 deletions
diff --git a/raslib/rmdebug.hh b/raslib/rmdebug.hh
index 08e38cc..6154c7d 100644
--- a/raslib/rmdebug.hh
+++ b/raslib/rmdebug.hh
@@ -89,14 +89,11 @@ extern int RManBenchmark;
#define RMDBCLASS( t1, t2, t3, t4, t5 ) ;
#endif
+// generate benchmark code only when RMANBENCHMARK is set
#ifdef RMANBENCHMARK
-
#define RMTIMER(class, func) RMTimer localRMTimer = RMTimer(class, func);
-
#else
-
#define RMTIMER(class, func)
-
#endif
//@ManMemo: Module: {\bf raslib}.
@@ -262,7 +259,7 @@ private:
/**
RMTimer is not strictly part of RasLib. It is a class used for taking
-timing measurements if compiling with RMANBENCHMARK defined. One way
+timing measurements if configuring with --benchmark-enabled. One way
of using it is to put the following at the beginning of a function:
{\tt RMTIMER("className", "functionName");}
@@ -329,6 +326,9 @@ public:
Time spent is the time since construction or last start() excluding
the times between pause() and resume().
*/
+ /// delivers current time count.
+ inline int getTime();
+
private:
/// name of class.
const char* myClass;
@@ -354,6 +354,8 @@ private:
long oldsec;
/// used to calculate time spent in function.
long oldusec;
+ /// aux function to determine clock time elapsed so far.
+ inline void fetchTime();
};
///Module: {\bf raslib}.
@@ -376,7 +378,7 @@ private:
bool doStuff;
};
-
#include "raslib/rmdebug.icc"
+
#endif
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
+}
+
diff --git a/raslib/rminit.hh b/raslib/rminit.hh
index fc1ef9e..df4eecb 100644
--- a/raslib/rminit.hh
+++ b/raslib/rminit.hh
@@ -165,7 +165,7 @@ class RMInit : public RM_Class
// could easily be done in rminit.cc. But the call to the constructor of RMInit
// has to get a flag for client ('C') or server ('S') as a parameter. This has
// be done somewhere else. In that case the constructor may be called before
-// initialization of the streams, the pogram crashes! If all initialisations
+// initialization of the streams, the program crashes! If all initialisations
// are in the same file, the order is defined. That is what this macro is for.
//
// Note: At some point it may be useful to reimplement this mess.