Dip  0.92.4
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. */
23 class UtilTimer {
24 private:
26  double startCpu_;
27  double finishCpu_;
28  double startReal_;
29  double finishReal_;
30 
32  double cpu_;
33 
35  double real_;
36 
37 public:
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() {
56  }
57 
59  inline void stop() {
64  }
65 
67  inline double getCpuTime() {
70  return cpu_;
71  }
72 
74  inline double getRealTime() {
77  return real_;
78  }
79 
82  inline bool isPast(double limit) {
83  return (getRealTime() > limit);
84  }
85 
86 };
87 
88 #endif
void start()
Start to count times.
Definition: UtilTimer.h:53
double cpu_
Cpu time.
Definition: UtilTimer.h:32
double finishCpu_
Definition: UtilTimer.h:27
double finishReal_
Definition: UtilTimer.h:29
double getCpuTime()
Get cpu time.
Definition: UtilTimer.h:67
double startCpu_
Start, end markers.
Definition: UtilTimer.h:26
bool isPast(double limit)
Return whether the given amount of real time has elapsed since the timer was started.
Definition: UtilTimer.h:82
double real_
Real clock time.
Definition: UtilTimer.h:35
static double CoinCpuTime()
Definition: CoinTime.hpp:106
double getRealTime()
Get wallClock time.
Definition: UtilTimer.h:74
void reset()
Reset.
Definition: UtilTimer.h:44
void stop()
Stop timer and computing times.
Definition: UtilTimer.h:59
double startReal_
Definition: UtilTimer.h:28
double CoinGetTimeOfDay()
Definition: CoinTime.hpp:69
~UtilTimer()
Definition: UtilTimer.h:41
UtilTimer()
Definition: UtilTimer.h:38