Dip-All  0.91.0
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 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // //
9 // Conceptual Design: Matthew Galati, SAS Institute Inc. //
10 // Ted Ralphs, Lehigh University //
11 // //
12 // Copyright (C) 2002-2015, Lehigh University, Matthew Galati, and Ted Ralphs//
13 // All Rights Reserved. //
14 //===========================================================================//
15 
16 #ifndef UTIL_TIMER_INCLUDED
17 #define UTIL_TIMER_INCLUDED
18 
19 //===========================================================================//
20 #include "CoinTime.hpp"
21 
22 //===========================================================================//
23 /* A timer used to record cpu and wallclock time. */
24 class UtilTimer {
25 private:
27  double startCpu_;
28  double finishCpu_;
29  double startReal_;
30  double finishReal_;
31 
33  double cpu_;
34 
36  double real_;
37 
38 public:
40  reset();
41  }
43 
45  inline void reset() {
46  start();
47  finishCpu_ = 0.0;
48  finishReal_ = 0.0;
49  cpu_ = 0.0;
50  real_ = 0.0;
51  }
52 
54  inline void start() {
57  }
58 
60  inline void stop() {
65  }
66 
68  inline double getCpuTime() {
71  return cpu_;
72  }
73 
75  inline double getRealTime() {
78  return real_;
79  }
80 
83  inline bool isPast(double limit) {
84  return (getRealTime() > limit);
85  }
86 
87 };
88 
89 #endif
void start()
Start to count times.
Definition: UtilTimer.h:54
double cpu_
Cpu time.
Definition: UtilTimer.h:33
double finishCpu_
Definition: UtilTimer.h:28
double finishReal_
Definition: UtilTimer.h:30
double getCpuTime()
Get cpu time.
Definition: UtilTimer.h:68
double startCpu_
Start, end markers.
Definition: UtilTimer.h:27
bool isPast(double limit)
Return whether the given amount of real time has elapsed since the timer was started.
Definition: UtilTimer.h:83
double real_
Real clock time.
Definition: UtilTimer.h:36
static double CoinCpuTime()
Definition: CoinTime.hpp:106
double getRealTime()
Get wallClock time.
Definition: UtilTimer.h:75
void reset()
Reset.
Definition: UtilTimer.h:45
void stop()
Stop timer and computing times.
Definition: UtilTimer.h:60
double startReal_
Definition: UtilTimer.h:29
double CoinGetTimeOfDay()
Definition: CoinTime.hpp:69
~UtilTimer()
Definition: UtilTimer.h:42
UtilTimer()
Definition: UtilTimer.h:39