COIN-OR::LEMON - Graph Library

source: lemon-0.x/test/counter_test.cc @ 1847:7cbc12e42482

Last change on this file since 1847:7cbc12e42482 was 1847:7cbc12e42482, checked in by Alpar Juttner, 18 years ago
  • Changed and improved Timer interface
    • several new member functions
    • reset() -> restart() renaming
    • TimeReport?: a Timer that prints a report on destruction.
  • counter.h: a tool to measure the number of streps of algorithms.
  • New documentation module for time measuring and counting.
File size: 1.4 KB
Line 
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
24int 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
33int 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}
Note: See TracBrowser for help on using the repository browser.