Ipopt Documentation  
 
Loading...
Searching...
No Matches
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// Authors: Andreas Waechter IBM 2005-09-19
6
7#ifndef __IPTIMEDTASK_HPP__
8#define __IPTIMEDTASK_HPP__
9
10#include "IpUtils.hpp"
11
12namespace Ipopt
13{
17{
18public:
21
23 :
24 total_cputime_(0.),
25 total_systime_(0.),
26 total_walltime_(0.),
27 start_called_(false),
28 end_called_(true)
29 {}
30
33 {}
35
37 void Reset()
38 {
39 total_cputime_ = 0.;
40 total_systime_ = 0.;
41 total_walltime_ = 0.;
42 start_called_ = false;
43 end_called_ = true;
44 }
45
47 void Start()
48 {
49 DBG_ASSERT(end_called_);
50 DBG_ASSERT(!start_called_);
51 end_called_ = false;
52 start_called_ = true;
53 start_cputime_ = CpuTime();
54 start_systime_ = SysTime();
55 start_walltime_ = WallclockTime();
56 }
57
59 void End()
60 {
61 DBG_ASSERT(!end_called_);
62 DBG_ASSERT(start_called_);
63 end_called_ = true;
64 start_called_ = false;
65 total_cputime_ += CpuTime() - start_cputime_;
66 total_systime_ += SysTime() - start_systime_;
67 total_walltime_ += WallclockTime() - start_walltime_;
68 }
69
75 {
76 if (start_called_)
77 {
78 end_called_ = true;
79 start_called_ = false;
80 total_cputime_ += CpuTime() - start_cputime_;
81 total_systime_ += SysTime() - start_systime_;
82 total_walltime_ += WallclockTime() - start_walltime_;
83 }
84 DBG_ASSERT(end_called_);
85 }
86
89 {
90 DBG_ASSERT(end_called_);
91 return total_cputime_;
92 }
93
96 {
97 DBG_ASSERT(end_called_);
98 return total_systime_;
99 }
100
103 {
104 DBG_ASSERT(end_called_);
105 return total_walltime_;
106 }
107
108private:
116
118
120 void operator=(const TimedTask&);
122
135
141
142};
143} // namespace Ipopt
144
145#endif
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:27
This class is used to collect timing information for a particular task.
Definition: IpTimedTask.hpp:17
Number start_walltime_
Wall clock time at beginning of task.
void EndIfStarted()
Method that is called after execution of the task for which timing might have been started.
Definition: IpTimedTask.hpp:74
~TimedTask()
Default destructor.
Definition: IpTimedTask.hpp:32
Number total_systime_
Total system time for task measured so far.
Number TotalCpuTime() const
Method returning total CPU time spend for task so far.
Definition: IpTimedTask.hpp:88
Number total_cputime_
Total CPU time for task measured so far.
void End()
Method that is called after execution of the task.
Definition: IpTimedTask.hpp:59
Number start_systime_
System time at beginning of task.
TimedTask(const TimedTask &)
Copy Constructor.
void Reset()
Method for resetting time to zero.
Definition: IpTimedTask.hpp:37
Number TotalSysTime() const
Method returning total system time spend for task so far.
Definition: IpTimedTask.hpp:95
TimedTask()
Default constructor.
Definition: IpTimedTask.hpp:22
void operator=(const TimedTask &)
Default Assignment Operator.
Number TotalWallclockTime() const
Method returning total wall clock time spend for task so far.
Number start_cputime_
CPU time at beginning of task.
Number total_walltime_
Total wall clock time for task measured so far.
void Start()
Method that is called before execution of the task.
Definition: IpTimedTask.hpp:47
#define IPOPTLIB_EXPORT
This file contains a base class for all exceptions and a set of macros to help with exceptions.
IPOPTLIB_EXPORT Number CpuTime()
method determining CPU time
IPOPTLIB_EXPORT Number SysTime()
method determining system time
IPOPTLIB_EXPORT Number WallclockTime()
method determining wallclock time since first call
double Number
Type of all numbers.
Definition: IpTypes.hpp:15