1 /*
2  * Copyright 2006-2008 The FLWOR Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /**
17  * Class to measure execution time based on CPU clocks and system time.
18  * made by Dongseop Kwon (subby@db.snu.ac.kr), 23/07/2003
19  */
20 
21 
22 #ifndef ZORBA_TIMER_H
23 #define ZORBA_TIMER_H
24 
25 #include <ctime>
26 #ifndef WIN32
27 #include <sys/time.h>
28 #else
29 #include <time.h>
30 #endif
31 
32 #include <iostream>
33 
34 
35 class Timer
36 {
37     clock_t startClock;
38     clock_t suspendClock;
39     clock_t endClock;
40 
41 #ifndef WIN32
42     double startTime;
43     double endTime;
44     double suspendTime;
45 #endif
46 
47 		bool suspended;
48     bool running;
49     bool verbose;
50 
51 public:
52     // timer routines
53     void start();
54     void end();
55     void suspend();
56     void resume();
57 
58     double getClock();
59     double getTime();
60 
61     // print all information
62     std::ostream& print(std::ostream& os);
63     bool isRunning();
64 
65   Timer(bool start = true, bool verbose = false);
66 };
67 #endif
68 
69 /*
70  * Local variables:
71  * mode: c++
72  * End:
73  */
74