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-2024 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file wallclocktimer.h
26 * @brief WallclockTimer class.
27 */
28
29#ifndef _WALLCLOCK_TIMER_H_
30#define _WALLCLOCK_TIMER_H_
31
32#include "soplex/spxdefines.h"
33#include "soplex/timer.h"
34
35namespace soplex
36{
37
38class WallclockTimer : public Timer
39{
40private:
41
42 //------------------------------------
43 /**@name Data */
44 ///@{
45 mutable time_t sec; ///< seconds
46 mutable time_t usec; ///< microseconds
47
48 mutable Real lasttime;
49 ///@}
50
51 //------------------------------------
52 /**@name Internal helpers */
53 ///@{
54 /// convert wallclock time to secounds.
55 Real wall2sec(time_t s, time_t us) const
56 {
57 return (Real)s + 0.000001 * (Real)us;
58 }
59
60 ///@}
61
62public:
63
64 //------------------------------------
65 /**@name Construction / destruction */
66 ///@{
67 /// default constructor
69 : Timer(), sec(0), usec(0), lasttime(0.0)
70 {}
71 /// copy constructor
73 : Timer(), sec(old.sec), usec(old.usec), lasttime(old.lasttime)
74 {}
75 /// assignment operator
77 {
78 sec = old.sec;
79 usec = old.usec;
80 lasttime = old.lasttime;
81 return *this;
82 }
83
85 {}
86 ///@}
87
88 //------------------------------------
89 /**@name Control */
90 ///@{
91 /// initialize timer, set timing accounts to zero.
92 virtual void reset()
93 {
94 status = RESET;
95 sec = usec = 0;
96 lasttime = 0.0;
97 }
98
99 /// start timer, resume accounting user, system and real time.
100 virtual void start();
101
102 /// stop timer, return accounted user time.
103 virtual Real stop();
104
105 /// return type of timer
106 virtual TYPE type()
107 {
108 return WALLCLOCK_TIME;
109 }
110 ///@}
111
112 //------------------------------------
113 /**@name Access */
114 ///@{
115 virtual Real time() const;
116
117 virtual Real lastTime() const;
118
119 ///@}
120};
121} // namespace soplex
122#endif // _WALLCLOCK_TIMER_H_
Wrapper for the system time query methods.
Definition: timer.h:86
TYPE
types of timers
Definition: timer.h:109
@ WALLCLOCK_TIME
Definition: timer.h:112
@ RESET
reset
Definition: timer.h:95
enum soplex::Timer::@19 status
status of the timer
virtual Real stop()
stop timer, return accounted user time.
virtual Real lastTime() const
WallclockTimer()
default constructor
WallclockTimer(const WallclockTimer &old)
copy constructor
virtual void start()
start timer, resume accounting user, system and real time.
WallclockTimer & operator=(const WallclockTimer &old)
assignment operator
virtual Real time() const
virtual void reset()
initialize timer, set timing accounts to zero.
Real wall2sec(time_t s, time_t us) const
convert wallclock time to secounds.
virtual TYPE type()
return type of timer
time_t usec
microseconds
Everything should be within this namespace.
double Real
Definition: spxdefines.h:269
Debugging, floating point type and parameter definitions.
Timer class.