timer.h
Go to the documentation of this file.
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 #ifndef ZORBA_UTIL_TIMER_H
18 #define ZORBA_UTIL_TIMER_H
19 
20 #include <zorba/util/time.h>
21 
22 namespace zorba
23 {
24 
25  namespace time
26  {
27 
28  class Timer {
29  public:
30  void start() {
31  get_current_walltime(theStart);
32  }
33 
34  double elapsed() const {
35  walltime lEnd;
37  return get_walltime_elapsed(theStart, lEnd);
38  }
39 
41  return get_walltime_in_millis(theStart);
42  }
43 
44  private:
45  walltime theStart;
46  };
47 
48  }
49 
50 }
51 
52 #endif
53 
54 /*
55  * Local variables:
56  * mode: c++
57  * End:
58  */
59 /* vim:set et sw=2 ts=2: */
msec_type get_walltime_in_millis(const walltime &t)
Definition: util/time.h:211
struct timeval walltime
Definition: util/time.h:198
void get_current_walltime(walltime &t)
Definition: util/time.h:206
void start()
Definition: timer.h:30
time::msec_type getStart() const
Definition: timer.h:40
long long msec_type
Definition: util/time.h:60
double elapsed() const
Definition: timer.h:34
double get_walltime_elapsed(const walltime &t0, const walltime &t1)
Definition: util/time.h:200