DOLFIN
DOLFIN C++ interface
Timer.h
1 // Copyright (C) 2008 Anders Logg, 2015 Jan Blechta
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // First added: 2008-06-13
19 // Last changed: 2010-11-16
20 
21 #ifndef __TIMER_H
22 #define __TIMER_H
23 
24 #include <string>
25 #include <tuple>
26 #include <boost/timer/timer.hpp>
27 
28 namespace dolfin
29 {
30 
46 
47  class Timer
48  {
49  public:
50 
52  Timer();
53 
55  Timer(std::string task);
56 
58  ~Timer();
59 
61  void start();
62 
64  void resume();
65 
68  double stop();
69 
73  std::tuple<double, double, double> elapsed() const;
74 
75  private:
76 
77  // Name of task
78  std::string _task;
79 
80  // Implementation of timer
81  boost::timer::cpu_timer _timer;
82 
83  };
84 
85 }
86 
87 #endif
~Timer()
Destructor.
Definition: Timer.cpp:39
std::tuple< double, double, double > elapsed() const
Definition: Timer.cpp:69
Definition: adapt.h:29
Definition: Timer.h:47
Timer()
Create timer without logging.
Definition: Timer.cpp:28
double stop()
Definition: Timer.cpp:60
void start()
Zero and start timer.
Definition: Timer.cpp:45
void resume()
Resume timer. Not well-defined for logging timer.
Definition: Timer.cpp:50