Dip 0.95.0
Loading...
Searching...
No Matches
UtilTimer.h
Go to the documentation of this file.
1//===========================================================================//
2// This file is part of the DIP Solver Framework. //
3// //
4// DIP is distributed under the Eclipse Public License as part of the //
5// COIN-OR repository (http://www.coin-or.org). //
6// //
7// Authors: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8// Ted Ralphs, Lehigh University (ted@lehigh.edu) //
9// Jiadong Wang, Lehigh University (jiw408@lehigh.edu) //
10// //
11// Copyright (C) 2002-2019, Lehigh University, Matthew Galati, and Ted Ralphs//
12// All Rights Reserved. //
13//===========================================================================//
14
15#ifndef UTIL_TIMER_INCLUDED
16#define UTIL_TIMER_INCLUDED
17
18//===========================================================================//
19#include "CoinTime.hpp"
20
21//===========================================================================//
22/* A timer used to record cpu and wallclock time. */
23class UtilTimer {
24private:
26 double startCpu_;
27 double finishCpu_;
28 double startReal_;
29 double finishReal_;
30
32 double cpu_;
33
35 double real_;
36
37public:
39 reset();
40 }
42
44 inline void reset() {
45 start();
46 finishCpu_ = 0.0;
47 finishReal_ = 0.0;
48 cpu_ = 0.0;
49 real_ = 0.0;
50 }
51
53 inline void start() {
54 startCpu_ = CoinCpuTime();
55 startReal_ = CoinGetTimeOfDay();
56 }
57
59 inline void stop() {
60 finishCpu_ = CoinCpuTime();
61 finishReal_ = CoinGetTimeOfDay();
62 cpu_ = finishCpu_ - startCpu_;
63 real_ = finishReal_ - startReal_;
64 }
65
67 inline double getCpuTime() {
68 finishCpu_ = CoinCpuTime();
69 cpu_ = finishCpu_ - startCpu_;
70 return cpu_;
71 }
72
74 inline double getRealTime() {
75 finishReal_ = CoinGetTimeOfDay();
76 real_ = finishReal_ - startReal_;
77 return real_;
78 }
79
82 inline bool isPast(double limit) {
83 return (getRealTime() > limit);
84 }
85
86};
87
88#endif
double CoinGetTimeOfDay()
double getRealTime()
Get wallClock time.
Definition: UtilTimer.h:74
~UtilTimer()
Definition: UtilTimer.h:41
UtilTimer()
Definition: UtilTimer.h:38
void reset()
Reset.
Definition: UtilTimer.h:44
void start()
Start to count times.
Definition: UtilTimer.h:53
double getCpuTime()
Get cpu time.
Definition: UtilTimer.h:67
void stop()
Stop timer and computing times.
Definition: UtilTimer.h:59
bool isPast(double limit)
Return whether the given amount of real time has elapsed since the timer was started.
Definition: UtilTimer.h:82