OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
timer.h
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #ifndef timer_h
36 #define timer_h
37 
38 #include "oofemcfg.h"
39 
40 #include <chrono>
41 
42 namespace oofem {
46 class OOFEM_EXPORT Timer
47 {
49  std :: chrono :: time_point< std :: chrono :: high_resolution_clock >start_wtime, end_wtime;
51  std :: chrono :: duration< double >start_utime, end_utime;
53  std :: chrono :: duration< double >elapsedWTime, elapsedUTime;
55  bool running;
56 
57 public:
58  Timer();
59 
60  void startTimer();
61  void stopTimer();
62  void pauseTimer();
63  void resumeTimer();
64  void initTimer();
65  bool isRunning() { return running; }
66 
68  double getUtime();
70  double getWtime();
71 
79  static void convert2HMS(int &nhrs, int &nmin, int &nsec, double tsec);
80 
82  void toString(char *buff);
83 
84  void updateElapsedTime();
85 
86 private:
88  void getUtime(std :: chrono :: duration< double > &answer);
90  void getTime(std :: chrono :: time_point< std :: chrono :: high_resolution_clock > &answer);
91 };
92 
98 class OOFEM_EXPORT EngngModelTimer
99 {
100 public:
115  EMTT_LastTimer
116  };
117 
118 protected:
120  Timer timers [ EMTT_LastTimer ];
121 
122 public:
125 
128  void startTimer(EngngModelTimerType t) { timers [ t ].startTimer(); }
129  void stopTimer(EngngModelTimerType t) { timers [ t ].stopTimer(); }
130  void pauseTimer(EngngModelTimerType t) { timers [ t ].pauseTimer(); }
131  void resumeTimer(EngngModelTimerType t) { timers [ t ].resumeTimer(); }
132  void initTimer(EngngModelTimerType t) { timers [ t ].initTimer(); }
134 
137  double getUtime(EngngModelTimerType t);
140  double getWtime(EngngModelTimerType t);
142  const Timer *getTimer(EngngModelTimerType t) { return timers + t; }
144  static void convert2HMS(int &nhrs, int &nmin, int &nsec, double tsec);
146  void toString(EngngModelTimerType t, char *buff);
148 };
149 } // end namespace oofem
150 #endif // timer_h
void pauseTimer(EngngModelTimerType t)
Definition: timer.h:130
const Timer * getTimer(EngngModelTimerType t)
Returns pointer to timer determined by EngngModelTimerType.
Definition: timer.h:142
std::chrono::duration< double > elapsedWTime
Accumulated wtime and utime (in seconds) from start.
Definition: timer.h:53
void startTimer(EngngModelTimerType t)
Definition: timer.h:128
void resumeTimer()
Definition: timer.C:91
void initTimer()
Definition: timer.C:98
std::chrono::time_point< std::chrono::high_resolution_clock > start_wtime
Wall clock time markers.
Definition: timer.h:49
void initTimer(EngngModelTimerType t)
Definition: timer.h:132
void stopTimer(EngngModelTimerType t)
Definition: timer.h:129
EngngModelTimerType
Enumeration to distinguish different type of timers.
Definition: timer.h:109
std::chrono::duration< double > start_utime
User time.
Definition: timer.h:51
void pauseTimer()
Definition: timer.C:83
Timer class, assumed to be an attribute of engineering model, serving stop-watch facility for enginee...
Definition: timer.h:98
bool isRunning()
Definition: timer.h:65
void resumeTimer(EngngModelTimerType t)
Definition: timer.h:131
Class implementing single timer, providing wall clock and user time capabilities. ...
Definition: timer.h:46
the oofem namespace is to define a context or scope in which all oofem names are defined.
void startTimer()
Definition: timer.C:69
bool running
Flag indicating whether timer is running.
Definition: timer.h:55
void stopTimer()
Definition: timer.C:77

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011