StopWatch.hpp
Go to the documentation of this file.
1 //===========================================================================
2 //
3 // File: StopWatch.hpp
4 //
5 // Created: Thu Jul 2 23:04:17 2009
6 //
7 // Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8 //
9 // $Date$
10 //
11 // $Revision$
12 //
13 //===========================================================================
14 
15 /*
16  Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
17  Copyright 2009, 2010 Statoil ASA.
18 
19  This file is part of the Open Porous Media project (OPM).
20 
21  OPM is free software: you can redistribute it and/or modify
22  it under the terms of the GNU General Public License as published by
23  the Free Software Foundation, either version 3 of the License, or
24  (at your option) any later version.
25 
26  OPM is distributed in the hope that it will be useful,
27  but WITHOUT ANY WARRANTY; without even the implied warranty of
28  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  GNU General Public License for more details.
30 
31  You should have received a copy of the GNU General Public License
32  along with OPM. If not, see <http://www.gnu.org/licenses/>.
33 */
34 
35 #ifndef OPM_STOPWATCH_HEADER
36 #define OPM_STOPWATCH_HEADER
37 
38 #include <boost/date_time/posix_time/posix_time.hpp>
39 
40 namespace Opm
41 {
42 
43  namespace time
44  {
45 
46  class StopWatch
47  {
48  public:
51  StopWatch();
52 
55  void start();
58  void stop();
59 
63  double secsSinceLast();
66  double secsSinceStart();
67 
68  private:
69  enum StopWatchState { UnStarted, Running, Stopped };
70 
71  StopWatchState state_;
72  boost::posix_time::ptime start_time_;
73  boost::posix_time::ptime last_time_;
74  boost::posix_time::ptime stop_time_;
75  };
76 
77  } // namespace time
78 
79 } // namespace Opm
80 
81 #endif // OPM_STOPWATCH_HEADER
Definition: AnisotropicEikonal.hpp:43
Definition: StopWatch.hpp:46