[Lemon-commits] [lemon_svn] alpar: r2993 - in hugo/trunk: lemon test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 21:51:42 CET 2006


Author: alpar
Date: Tue Oct 17 12:31:20 2006
New Revision: 2993

Modified:
   hugo/trunk/lemon/time_measure.h
   hugo/trunk/test/time_measure_test.cc

Log:
Change for better measurement very fast operations (enable a higher
number of iterations in runningTimeTest())

Modified: hugo/trunk/lemon/time_measure.h
==============================================================================
--- hugo/trunk/lemon/time_measure.h	(original)
+++ hugo/trunk/lemon/time_measure.h	Tue Oct 17 12:31:20 2006
@@ -517,22 +517,19 @@
   ///\return The average running time of \c f.
   
   template<class F>
-  TimeStamp runningTimeTest(F f,double min_time=10,int *num = NULL,
+  TimeStamp runningTimeTest(F f,double min_time=10,unsigned int *num = NULL,
                             TimeStamp *full_time=NULL)
   {
-    Timer t;
     TimeStamp full;
-    int total=0;
-    for(int tn=1;tn < 1<<30; tn*=2) {
+    unsigned int total=0;
+    Timer t;
+    for(unsigned int tn=1;tn <= 1<<31 && full.realTime()<=min_time; tn*=2) {
       for(;total<tn;total++) f();
       full=t;
-      if(full.realTime()>min_time) {
-	if(num) *num=total;
-	if(full_time) *full_time=full;
-      return full/total;
-      }
     }
-    return TimeStamp();
+    if(num) *num=total;
+    if(full_time) *full_time=full;
+    return full/total;
   }
   
   /// @}  

Modified: hugo/trunk/test/time_measure_test.cc
==============================================================================
--- hugo/trunk/test/time_measure_test.cc	(original)
+++ hugo/trunk/test/time_measure_test.cc	Tue Oct 17 12:31:20 2006
@@ -43,7 +43,7 @@
 int main()
 {
   Timer T;
-  int n;
+  unsigned int n;
   for(n=0;T.realTime()<1.0;n++) ;
   std::cout << T << " (" << n << " time queries)\n";
   T.restart();



More information about the Lemon-commits mailing list