Ipopt
3.11.8
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Common
IpTimedTask.hpp
Go to the documentation of this file.
1
// Copyright (C) 2006, 2009 International Business Machines and others.
2
// All Rights Reserved.
3
// This code is published under the Eclipse Public License.
4
//
5
// $Id: IpTimedTask.hpp 1861 2010-12-21 21:34:47Z andreasw $
6
//
7
// Authors: Andreas Waechter IBM 2005-09-19
8
9
#ifndef __IPTIMEDTASK_HPP__
10
#define __IPTIMEDTASK_HPP__
11
12
#include "
IpUtils.hpp
"
13
14
namespace
Ipopt
15
{
18
class
TimedTask
19
{
20
public
:
24
TimedTask
()
25
:
26
total_cputime_
(0.),
27
total_systime_
(0.),
28
total_walltime_
(0.),
29
start_called_
(false),
30
end_called_
(true)
31
{}
32
34
~TimedTask
()
35
{}
37
39
void
Reset
()
40
{
41
total_cputime_
= 0.;
42
total_systime_
= 0.;
43
total_walltime_
= 0.;
44
start_called_
=
false
;
45
end_called_
=
true
;
46
}
47
49
void
Start
()
50
{
51
DBG_ASSERT
(
end_called_
);
52
DBG_ASSERT
(!
start_called_
);
53
end_called_
=
false
;
54
start_called_
=
true
;
55
start_cputime_
=
CpuTime
();
56
start_systime_
=
SysTime
();
57
start_walltime_
=
WallclockTime
();
58
}
59
61
void
End
()
62
{
63
DBG_ASSERT
(!
end_called_
);
64
DBG_ASSERT
(
start_called_
);
65
end_called_
=
true
;
66
start_called_
=
false
;
67
total_cputime_
+=
CpuTime
() -
start_cputime_
;
68
total_systime_
+=
SysTime
() -
start_systime_
;
69
total_walltime_
+=
WallclockTime
() -
start_walltime_
;
70
}
71
76
void
EndIfStarted
()
77
{
78
if
(
start_called_
) {
79
end_called_
=
true
;
80
start_called_
=
false
;
81
total_cputime_
+=
CpuTime
() -
start_cputime_
;
82
total_systime_
+=
SysTime
() -
start_systime_
;
83
total_walltime_
+=
WallclockTime
() -
start_walltime_
;
84
}
85
DBG_ASSERT
(
end_called_
);
86
}
87
89
Number
TotalCpuTime
()
const
90
{
91
DBG_ASSERT
(
end_called_
);
92
return
total_cputime_
;
93
}
94
96
Number
TotalSysTime
()
const
97
{
98
DBG_ASSERT
(
end_called_
);
99
return
total_systime_
;
100
}
101
103
Number
TotalWallclockTime
()
const
104
{
105
DBG_ASSERT
(
end_called_
);
106
return
total_walltime_
;
107
}
108
109
private
:
118
TimedTask
(
const
TimedTask
&);
119
121
void
operator=
(
const
TimedTask
&);
123
125
Number
start_cputime_
;
127
Number
total_cputime_
;
129
Number
start_systime_
;
131
Number
total_systime_
;
133
Number
start_walltime_
;
135
Number
total_walltime_
;
136
139
bool
start_called_
;
140
bool
end_called_
;
142
143
};
144
}
// namespace Ipopt
145
146
#endif
Generated by
1.8.3.1