COIN-OR::LEMON - Graph Library

source: lemon-main/test/counter_test.cc @ 122:35840c5aa696

Last change on this file since 122:35840c5aa696 was 119:82a2639a05bb, checked in by Alpar Juttner <alpar@…>, 17 years ago

Port time and counter utilities from svn -r3482
The mingw support has been removed

File size: 1.4 KB
RevLine 
[119]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
26int 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
35int 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}
Note: See TracBrowser for help on using the repository browser.