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