Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
timermap.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2007-05-23
7 
8  Copyright (C) 2007,2009 Université de Grenoble 1
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __TimerMap_H
30 #define __TimerMap_H 1
31 
32 #include <boost/timer.hpp>
33 
34 namespace Feel
35 {
36 struct TimerPair : public std::pair<boost::timer, double>
37 {
38 public:
39 
40  double elapsed()
41  {
42  second = first.elapsed();
43  return second;
44  }
45  void accumulate()
46  {
47  second += first.elapsed();
48  first.restart();
49  }
50  void restart()
51  {
52  first.restart();
53  }
54  void reset()
55  {
56  first.restart();
57  second = 0;
58  }
59 };
67 class TimerMap : public std::map<std::string, TimerPair>
68 {
69  typedef std::map<std::string, TimerPair> super;
70 public:
71 
72 
73 
77 
78  typedef super::iterator iterator;
79  typedef super::const_iterator const_iterator;
80 
82 
86 
87  TimerMap() {}
88  TimerMap( TimerMap const & tm ) : super( tm ) {}
89  ~TimerMap() {}
90 
92 
96 
97 
99 
103 
104 
106 
110 
111 
113 
117 
118  template<typename PrefixType>
119  void report( PrefixType const& prefix )
120  {
121  const_iterator it;
122 
123  for ( it=this->begin(); it!=this->end(); ++it )
124  {
125  VLOG(1) << prefix << " " << it->first << ": " << it->second.second << "\n";
126  }
127  }
128 
130 
131 
132 
133 protected:
134 
135 private:
136 
137 };
138 } // Feel
139 #endif /* __TimerMap_H */
timers map
Definition: timermap.hpp:67

Generated on Sun Dec 22 2013 13:11:15 for Feel++ by doxygen 1.8.5