Carmen Code
 All Classes Files Functions Variables Macros Pages
Timer.h
Go to the documentation of this file.
1 /***************************************************************************
2  Timer.h - description
3  -------------------
4  begin : Thu Jun 7 2001
5  copyright : (C) 2001 by Olivier Roussel & Alexei Tsigulin
6  email : roussel@ict.uni-karlsruhe.de, lpsoft@mail.ru
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef TIMER_H
19 #define TIMER_H
20 #include <time.h>
21 #include <sys/times.h>
22 #include "PreProcessor.h"
23 
24 
31 class Timer
32 {
33 /*
34 ______________________________________________________________________________________________
35 
36 PUBLIC METHODS
37 ______________________________________________________________________________________________
38 
39 */
40 
41 public:
46  Timer();
47 
53 void resetStart();
54 
62 void check();
63 
69 void start();
70 
76 double stop();
77 
83 double CPUTime();
84 
90 double realTime();
91 
99 void add(double cpuTime, double realTime);
100 
101 
102 /*
103 ______________________________________________________________________________________________
104 
105 PRIVATE VARIABLES
106 ______________________________________________________________________________________________
107 
108 */
109 private:
110 
111  clock_t StartCPUTime;
112  time_t StartRealTime;
113  double sumCPUtime;
114  double sumRealtime;
116  bool TimerOn;
117 };
118 
119 #endif
double CPUTime()
Returns CPU time from previous start in seconds.
Definition: Timer.cpp:124
void add(double cpuTime, double realTime)
Adds time to buffer (only when a computation is restarted).
Definition: Timer.cpp:173
double stop()
Stop timer and, if asked, returns CPU time from previous start in seconds.
Definition: Timer.cpp:77
double realTime()
Returns real time from previous start in seconds.
Definition: Timer.cpp:148
Timer()
Constructor of Timer class. Initialize timer.
Definition: Timer.cpp:30
void resetStart()
Resets time and start.
Definition: Timer.cpp:46
void start()
Starts timer.
Definition: Timer.cpp:62
void check()
Adds CPU time and real time to their buffers and resets. For long computations, it is recommended to ...
Definition: Timer.cpp:103
An object Timer gives information on the CPU time of long-time computations.
Definition: Timer.h:31