test/time_measure_test.cc
changeset 292 e7af73f1805e
parent 171 02f4d5d9bfd7
child 440 88ed40ad0d4f
equal deleted inserted replaced
1:2304afb3e08e 2:d4b02bc87d14
     1 /* -*- C++ -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2008
     5  * Copyright (C) 2003-2008
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
    18 
    18 
    19 #include <lemon/time_measure.h>
    19 #include <lemon/time_measure.h>
    20 
    20 
    21 using namespace lemon;
    21 using namespace lemon;
    22 
    22 
    23 void f() 
    23 void f()
    24 {
    24 {
    25   double d=0;
    25   double d=0;
    26   for(int i=0;i<1000;i++)
    26   for(int i=0;i<1000;i++)
    27     d+=0.1;
    27     d+=0.1;
    28 }
    28 }
    29 
    29 
    30 void g() 
    30 void g()
    31 {
    31 {
    32   static Timer T;
    32   static Timer T;
    33   
    33 
    34   for(int i=0;i<1000;i++)
    34   for(int i=0;i<1000;i++)
    35     TimeStamp x(T);
    35     TimeStamp x(T);
    36 }
    36 }
    37 
    37 
    38 int main()
    38 int main()
    47   TimeStamp full;
    47   TimeStamp full;
    48   TimeStamp t;
    48   TimeStamp t;
    49   t=runningTimeTest(f,1,&n,&full);
    49   t=runningTimeTest(f,1,&n,&full);
    50   std::cout << t << " (" << n << " tests)\n";
    50   std::cout << t << " (" << n << " tests)\n";
    51   std::cout << "Total: " << full << "\n";
    51   std::cout << "Total: " << full << "\n";
    52   
    52 
    53   t=runningTimeTest(g,1,&n,&full);
    53   t=runningTimeTest(g,1,&n,&full);
    54   std::cout << t << " (" << n << " tests)\n";
    54   std::cout << t << " (" << n << " tests)\n";
    55   std::cout << "Total: " << full << "\n";
    55   std::cout << "Total: " << full << "\n";
    56   
    56 
    57   return 0;
    57   return 0;
    58 }
    58 }