Scippy

SoPlex

Sequential object-oriented simPlex

wallclocktimer.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file wallclocktimer.h
17  * @brief WallclockTimer class.
18  */
19 
20 #ifndef _WALLCLOCK_TIMER_H_
21 #define _WALLCLOCK_TIMER_H_
22 
23 #include "soplex/spxdefines.h"
24 #include "soplex/timer.h"
25 
26 namespace soplex
27 {
28 
29 class WallclockTimer : public Timer
30 {
31 private:
32 
33  //------------------------------------
34  /**@name Data */
35  //@{
36  mutable long sec; ///< seconds
37  mutable long usec; ///< microseconds
38 
39  mutable Real lasttime;
40  //@}
41 
42  //------------------------------------
43  /**@name Internal helpers */
44  //@{
45  /// convert wallclock time to secounds.
46  Real wall2sec(long s, long us) const
47  {
48  return (Real)s + 0.000001 * (Real)us;
49  }
50 
51  //@}
52 
53 public:
54 
55  //------------------------------------
56  /**@name Construction / destruction */
57  //@{
58  /// default constructor
60  : Timer(), sec(0), usec(0), lasttime(0.0)
61  {}
62  /// copy constructor
64  : Timer(), sec(old.sec), usec(old.usec), lasttime(old.lasttime)
65  {}
66  /// assignment operator
68  {
69  sec = old.sec;
70  usec = old.usec;
71  lasttime = old.lasttime;
72  return *this;
73  }
74 
75  virtual ~WallclockTimer()
76  {}
77  //@}
78 
79  //------------------------------------
80  /**@name Control */
81  //@{
82  /// initialize timer, set timing accounts to zero.
83  virtual void reset()
84  {
85  status = RESET;
86  sec = usec = 0;
87  lasttime = 0.0;
88  }
89 
90  /// start timer, resume accounting user, system and real time.
91  virtual void start();
92 
93  /// stop timer, return accounted user time.
94  virtual Real stop();
95 
96  /// return type of timer
97  virtual TYPE type()
98  {
99  return WALLCLOCK_TIME;
100  }
101  //@}
102 
103  //------------------------------------
104  /**@name Access */
105  //@{
106  virtual Real time() const;
107 
108  virtual Real lastTime() const;
109 
110  //@}
111 };
112 } // namespace soplex
113 #endif // _WALLCLOCK_TIMER_H_
Real wall2sec(long s, long us) const
convert wallclock time to secounds.
long usec
microseconds
virtual void reset()
initialize timer, set timing accounts to zero.
virtual Real time() const
WallclockTimer(const WallclockTimer &old)
copy constructor
virtual Real lastTime() const
enum soplex::Timer::@2 status
status of the timer
double Real
Definition: spxdefines.h:218
virtual void start()
start timer, resume accounting user, system and real time.
virtual TYPE type()
return type of timer
Debugging, floating point type and parameter definitions.
Everything should be within this namespace.
Timer class.
TYPE
types of timers
Definition: timer.h:99
WallclockTimer()
default constructor
WallclockTimer & operator=(const WallclockTimer &old)
assignment operator
virtual Real stop()
stop timer, return accounted user time.
Wrapper for the system time query methods.
Definition: timer.h:76