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