Vaucanson 1.4
|
00001 // bencher.hh: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // Copyright (C) 2007 The Vaucanson Group. 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License, or any later version. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 // 00020 00021 #ifndef BENCHER_HH 00022 # define BENCHER_HH 00023 00024 // STL 00025 # include <vector> 00026 # include <iostream> 00027 00028 // CBS 00029 # include <cbs/bench/timer.hh> 00030 00031 // Vaucanson 00032 # ifdef VAUCANSON 00033 # define NAMESPACE_VCSN_BEGIN namespace vcsn { 00034 # define NAMESPACE_VCSN_END } // namespace vcsn 00035 # include <vaucanson/misc/contract.hh> 00036 # else 00037 # define NAMESPACE_VCSN_BEGIN 00038 # define NAMESPACE_VCSN_END 00039 # include <cassert> 00040 # define precondition(C) assert(C) 00041 # endif 00042 00043 NAMESPACE_VCSN_BEGIN 00044 00045 namespace misc 00046 { 00047 class Bencher 00048 { 00049 public: 00051 void push (const timer::Timer& t); 00052 00054 std::ostream& print (std::ostream& o) const; 00055 00056 void plot (std::ostream& o) const; 00057 00059 timer::Timer sum() const; 00060 00062 timer::Timer mean() const; 00063 00065 timer::Timer min() const; 00066 00068 timer::Timer max() const; 00069 00070 private: 00072 timer::Timer prepare (timer::Timer t) const; 00073 00075 std::vector<timer::Timer> timers_; 00076 }; 00077 00078 00080 std::ostream& operator<< (std::ostream& o, const Bencher& t); 00081 } 00082 00083 NAMESPACE_VCSN_END 00084 00085 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00086 # include <vaucanson/misc/bencher.hxx> 00087 # if VAUCANSON 00088 # include <vaucanson/misc/bencher.cc> 00089 # endif 00090 # endif // VCSN_USE_INTERFACE_ONLY 00091 00092 #endif // !BENCHER_HH