Scippy

SoPlex

Sequential object-oriented simPlex

usertimer.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-2016 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 usertimer.h
17  * @brief UserTimer class.
18  */
19 
20 #ifndef _USER_TIMER_H_
21 #define _USER_TIMER_H_
22 
23 #include "spxdefines.h"
24 #include "timer.h"
25 
26 namespace soplex
27 {
28 
29 class UserTimer : public Timer
30 {
31 private:
32 
33  //------------------------------------
34  /**@name number of ticks per second */
35  //@{
36  static const long ticks_per_sec; ///< ticks per secound, should be constant
37  //@}
38 
39  //------------------------------------
40  /**@name Data */
41  //@{
42  mutable long uAccount; ///< user time
43  mutable long uTicks; ///< user ticks
44 
45  mutable Real lasttime;
46  //@}
47 
48  //------------------------------------
49  /**@name Internal helpers */
50  //@{
51  /// convert ticks to secounds.
52  Real ticks2sec(long ticks) const
53  {
54  return (Real(ticks) * 1000.0 / Real(ticks_per_sec)) / 1000.0;
55  }
56 
57  /// get actual user ticks from the system.
58  void updateTicks() const;
59 
60  //@}
61 
62 public:
63 
64  //------------------------------------
65  /**@name Construction / destruction */
66  //@{
67  /// default constructor
69  : Timer(), uAccount(0), uTicks(0), lasttime(0.0)
70  {
71  assert(ticks_per_sec > 0);
72  }
73  /// copy constructor
74  UserTimer(const UserTimer& old)
75  : Timer(), uAccount(old.uAccount), uTicks(old.uTicks), lasttime(old.lasttime)
76  {
77  assert(ticks_per_sec > 0);
78  }
79  /// assignment operator
81  {
82  assert(ticks_per_sec > 0);
83  uAccount = old.uAccount;
84  uTicks = old.uTicks;
85  lasttime = old.lasttime;
86  return *this;
87  }
88 
89  virtual ~UserTimer()
90  {}
91  //@}
92 
93  //------------------------------------
94  /**@name Control */
95  //@{
96  /// initialize timer, set timing accounts to zero.
97  virtual void reset()
98  {
99  status = RESET;
100  uAccount = 0;
101  lasttime = 0.0;
102  }
103 
104  /// start timer, resume accounting user, system and real time.
105  virtual void start();
106 
107  /// stop timer, return accounted user time.
108  virtual Real stop();
109 
110  /// return type of timer
111  virtual TYPE type()
112  {
113  return USER_TIME;
114  }
115  //@}
116 
117  //------------------------------------
118  /**@name Access */
119  //@{
120  virtual Real time() const;
121 
122  virtual Real lastTime() const;
123  //@}
124 };
125 } // namespace soplex
126 #endif // _USER_TIMER_H_
long uAccount
user time
Definition: usertimer.h:42
UserTimer(const UserTimer &old)
copy constructor
Definition: usertimer.h:74
void updateTicks() const
get actual user ticks from the system.
Definition: usertimer.cpp:52
long uTicks
user ticks
Definition: usertimer.h:43
double Real
SOPLEX_DEBUG.
Definition: spxdefines.h:200
virtual Real lastTime() const
Definition: usertimer.cpp:114
virtual Real time() const
Definition: usertimer.cpp:100
UserTimer()
default constructor
Definition: usertimer.h:68
virtual Real stop()
stop timer, return accounted user time.
Definition: usertimer.cpp:86
enum soplex::Timer::@18 status
status of the timer
virtual void start()
start timer, resume accounting user, system and real time.
Definition: usertimer.cpp:72
Debugging, floating point type and parameter definitions.
Everything should be within this namespace.
Timer class.
TYPE
types of timers
Definition: timer.h:99
virtual TYPE type()
return type of timer
Definition: usertimer.h:111
virtual void reset()
initialize timer, set timing accounts to zero.
Definition: usertimer.h:97
virtual ~UserTimer()
Definition: usertimer.h:89
Real ticks2sec(long ticks) const
convert ticks to secounds.
Definition: usertimer.h:52
static const long ticks_per_sec
ticks per secound, should be constant
Definition: usertimer.h:36
UserTimer & operator=(const UserTimer &old)
assignment operator
Definition: usertimer.h:80
Wrapper for the system time query methods.
Definition: timer.h:76