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