test/counter_test.cc
changeset 165 b4c336c27a03
child 171 02f4d5d9bfd7
equal deleted inserted replaced
-1:000000000000 0:d4f7b97605a4
       
     1 /* -*- C++ -*-
       
     2  *
       
     3  * This file is a part of LEMON, a generic C++ optimization library
       
     4  *
       
     5  * Copyright (C) 2003-2008
       
     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/counter.h>
       
    20 
       
    21 ///\file \brief Test cases for time_measure.h
       
    22 ///
       
    23 ///\todo To be extended
       
    24 
       
    25 
       
    26 int fibonacci(int f) 
       
    27 {
       
    28   static lemon::Counter count("Fibonacci steps: ");
       
    29   count++;
       
    30   if(f<1) return 0;
       
    31   else if(f==1) return 1;
       
    32   else return fibonacci(f-1)+fibonacci(f-2);
       
    33 }
       
    34 
       
    35 int main()
       
    36 {
       
    37   fibonacci(10);
       
    38   
       
    39   {  
       
    40     typedef lemon::Counter MyCounter;
       
    41     MyCounter c("Main counter: ");
       
    42     c++;
       
    43     c++;
       
    44     MyCounter::SubCounter d(c,"Subcounter: ");
       
    45     d++;
       
    46     d++;
       
    47     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
       
    48     e++;
       
    49     e++;
       
    50   }
       
    51   
       
    52   {
       
    53     typedef lemon::NoCounter MyCounter;
       
    54     MyCounter c("Main counter: ");
       
    55     c++;
       
    56     c++;
       
    57     MyCounter::SubCounter d(c,"Subcounter: ");
       
    58     d++;
       
    59     d++;
       
    60     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
       
    61     e++;
       
    62     e++;
       
    63   }
       
    64 
       
    65   return 0;
       
    66 }