test/counter_test.cc
author hegyi
Tue, 06 Dec 2005 10:53:38 +0000
changeset 1849 a4d1362397fe
child 1875 98698b69a902
permissions -rw-r--r--
Notebook style is provided. Without opportunity to close tabs. :-) But with all other necessary things (I think).
     1 /* -*- C++ -*-
     2  * test/counter_test.cc - Part of LEMON, a generic C++ optimization library
     3  *
     4  * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     5  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     6  *
     7  * Permission to use, modify and distribute this software is granted
     8  * provided that this copyright notice appears in all copies. For
     9  * precise terms see the accompanying LICENSE file.
    10  *
    11  * This software is provided "AS IS" with no warranty of any kind,
    12  * express or implied, and with no claim as to its suitability for any
    13  * purpose.
    14  *
    15  */
    16 
    17 #include <lemon/counter.h>
    18 
    19 ///\file \brief Test cases for time_measure.h
    20 ///
    21 ///\todo To be extended
    22 
    23 
    24 int fibonacci(int f) 
    25 {
    26   static lemon::Counter count("Fibonacci steps: ");
    27   count++;
    28   if(f<1) return 0;
    29   else if(f==1) return 1;
    30   else return fibonacci(f-1)+fibonacci(f-2);
    31 }
    32 
    33 int main()
    34 {
    35   fibonacci(10);
    36   
    37   {  
    38     typedef lemon::Counter MyCounter;
    39     MyCounter c("Main counter: ");
    40     c++;
    41     c++;
    42     MyCounter::SubCounter d(c,"Subcounter: ");
    43     d++;
    44     d++;
    45     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
    46     e++;
    47     e++;
    48   }
    49   
    50   {
    51     typedef lemon::NoCounter MyCounter;
    52     MyCounter c("Main counter: ");
    53     c++;
    54     c++;
    55     MyCounter::SubCounter d(c,"Subcounter: ");
    56     d++;
    57     d++;
    58     MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: ");
    59     e++;
    60     e++;
    61   }
    62 
    63   return 0;
    64 }