Vaucanson  1.4.1
bencher.hh
1 // bencher.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 // Copyright (C) 2007 The Vaucanson Group.
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 
21 #ifndef BENCHER_HH
22 # define BENCHER_HH
23 
24 // STL
25 # include <vector>
26 # include <iostream>
27 
28 // CBS
29 # include <cbs/bench/timer.hh>
30 
31 // Vaucanson
32 # ifdef VAUCANSON
33 # define NAMESPACE_VCSN_BEGIN namespace vcsn {
34 # define NAMESPACE_VCSN_END } // namespace vcsn
36 # else
37 # define NAMESPACE_VCSN_BEGIN
38 # define NAMESPACE_VCSN_END
39 # include <cassert>
40 # define precondition(C) assert(C)
41 # endif
42 
43 NAMESPACE_VCSN_BEGIN
44 
45 namespace misc
46 {
47  class Bencher
48  {
49  public:
51  void push (const timer::Timer& t);
52 
54  std::ostream& print (std::ostream& o) const;
55 
56  void plot (std::ostream& o) const;
57 
59  timer::Timer sum() const;
60 
62  timer::Timer mean() const;
63 
65  timer::Timer min() const;
66 
68  timer::Timer max() const;
69 
70  private:
72  timer::Timer prepare (timer::Timer t) const;
73 
75  std::vector<timer::Timer> timers_;
76  };
77 
78 
80  std::ostream& operator<< (std::ostream& o, const Bencher& t);
81 }
82 
83 NAMESPACE_VCSN_END
84 
85 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
86 # include <vaucanson/misc/bencher.hxx>
87 # if VAUCANSON
88 # include <vaucanson/misc/bencher.cc>
89 # endif
90 # endif // VCSN_USE_INTERFACE_ONLY
91 
92 #endif // !BENCHER_HH