test/time_measure_test.cc
changeset 1964 df0b07457083
parent 1956 a055123339d5
child 1972 487a868e30e5
equal deleted inserted replaced
4:4c21cf12440f 5:dcdb6c45b569
    26 using namespace lemon;
    26 using namespace lemon;
    27 
    27 
    28 void f() 
    28 void f() 
    29 {
    29 {
    30   double d=0;
    30   double d=0;
    31   for(int i=0;i<10000;i++)
    31   for(int i=0;i<1000;i++)
    32     d+=0.1;
    32     d+=0.1;
       
    33 }
       
    34 
       
    35 void g() 
       
    36 {
       
    37   static Timer T;
       
    38   
       
    39   double d=0;
       
    40   for(int i=0;i<1000;i++)
       
    41     TimeStamp x(T);
    33 }
    42 }
    34 
    43 
    35 int main()
    44 int main()
    36 {
    45 {
    37   Timer T;
    46   Timer T;
    40   std::cout << T << " (" << n << " time queries)\n";
    49   std::cout << T << " (" << n << " time queries)\n";
    41   T.restart();
    50   T.restart();
    42   while(T.realTime()<2.0) ;
    51   while(T.realTime()<2.0) ;
    43   std::cout << T << '\n';
    52   std::cout << T << '\n';
    44   TimeStamp full;
    53   TimeStamp full;
    45   TimeStamp t=runningTimeTest(f,1,&n,&full);
    54   TimeStamp t;
       
    55   t=runningTimeTest(f,1,&n,&full);
       
    56   std::cout << t << " (" << n << " tests)\n";
       
    57   std::cout << "Total: " << full << "\n";
       
    58   
       
    59   t=runningTimeTest(g,1,&n,&full);
    46   std::cout << t << " (" << n << " tests)\n";
    60   std::cout << t << " (" << n << " tests)\n";
    47   std::cout << "Total: " << full << "\n";
    61   std::cout << "Total: " << full << "\n";
    48   
    62   
    49   return 0;
    63   return 0;
    50 }
    64 }