alpar@1847: /* -*- C++ -*- alpar@1847: * test/counter_test.cc - Part of LEMON, a generic C++ optimization library alpar@1847: * alpar@1847: * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1847: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@1847: * alpar@1847: * Permission to use, modify and distribute this software is granted alpar@1847: * provided that this copyright notice appears in all copies. For alpar@1847: * precise terms see the accompanying LICENSE file. alpar@1847: * alpar@1847: * This software is provided "AS IS" with no warranty of any kind, alpar@1847: * express or implied, and with no claim as to its suitability for any alpar@1847: * purpose. alpar@1847: * alpar@1847: */ alpar@1847: alpar@1847: #include alpar@1847: alpar@1847: ///\file \brief Test cases for time_measure.h alpar@1847: /// alpar@1847: ///\todo To be extended alpar@1847: alpar@1847: alpar@1847: int fibonacci(int f) alpar@1847: { alpar@1847: static lemon::Counter count("Fibonacci steps: "); alpar@1847: count++; alpar@1847: if(f<1) return 0; alpar@1847: else if(f==1) return 1; alpar@1847: else return fibonacci(f-1)+fibonacci(f-2); alpar@1847: } alpar@1847: alpar@1847: int main() alpar@1847: { alpar@1847: fibonacci(10); alpar@1847: alpar@1847: { alpar@1847: typedef lemon::Counter MyCounter; alpar@1847: MyCounter c("Main counter: "); alpar@1847: c++; alpar@1847: c++; alpar@1847: MyCounter::SubCounter d(c,"Subcounter: "); alpar@1847: d++; alpar@1847: d++; alpar@1847: MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: "); alpar@1847: e++; alpar@1847: e++; alpar@1847: } alpar@1847: alpar@1847: { alpar@1847: typedef lemon::NoCounter MyCounter; alpar@1847: MyCounter c("Main counter: "); alpar@1847: c++; alpar@1847: c++; alpar@1847: MyCounter::SubCounter d(c,"Subcounter: "); alpar@1847: d++; alpar@1847: d++; alpar@1847: MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: "); alpar@1847: e++; alpar@1847: e++; alpar@1847: } alpar@1847: alpar@1847: return 0; alpar@1847: }