test/time_measure_test.cc
author Balazs Dezso <deba@inf.elte.hu>
Thu, 24 Jun 2010 09:27:53 +0200
changeset 982 bb70ad62c95f
parent 463 88ed40ad0d4f
child 1157 761fe0846f49
permissions -rw-r--r--
Fix critical bug in preflow (#372)

The wrong transition between the bound decrease and highest active
heuristics caused the bug. The last node chosen in bound decrease mode
is used in the first iteration in highest active mode.
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     5  * Copyright (C) 2003-2009
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #include <lemon/time_measure.h>
    20 
    21 using namespace lemon;
    22 
    23 void f()
    24 {
    25   double d=0;
    26   for(int i=0;i<1000;i++)
    27     d+=0.1;
    28 }
    29 
    30 void g()
    31 {
    32   static Timer T;
    33 
    34   for(int i=0;i<1000;i++)
    35     TimeStamp x(T);
    36 }
    37 
    38 int main()
    39 {
    40   Timer T;
    41   unsigned int n;
    42   for(n=0;T.realTime()<0.1;n++) ;
    43   std::cout << T << " (" << n << " time queries)\n";
    44 
    45   TimeStamp full;
    46   TimeStamp t;
    47   t=runningTimeTest(f,0.1,&n,&full);
    48   std::cout << t << " (" << n << " tests)\n";
    49   std::cout << "Total: " << full << "\n";
    50 
    51   t=runningTimeTest(g,0.1,&n,&full);
    52   std::cout << t << " (" << n << " tests)\n";
    53   std::cout << "Total: " << full << "\n";
    54 
    55   return 0;
    56 }