ATLAS Offline Software
DataQuality/HanConfigGenerator/src/simpletimer.h
Go to the documentation of this file.
1 // emacs: this is -*- c++ -*-
2 //
3 // @file simpletimer.h
4 // these functions have a precision of about 0.001 ms
5 //
6 //
7 // Copyright (C) 2007 M.Sutton (sutt@hep.ucl.ac.uk)
8 //
9 // $Id: simpletimer.h, v0.0 Thu 22 Jan 2009 15:51:52 GMT sutt $
10 
11 
12 #ifndef __SIMPLETIMER_H
13 #define __SIMPLETIMER_H
14 
15 #include <time.h>
16 #include <sys/time.h>
17 
18 //#ifdef __cplusplus
19 //extern "C" {
20 //#endif
21 
22 
23 inline struct timeval simpletimer_start(void) {
24  struct timeval start_time;
25  gettimeofday(&start_time, NULL);
26  return start_time;
27 }
28 
29 inline double simpletimer_stop(const struct timeval& start_time)
30 {
31  struct timeval stop_time;
32  struct timeval diff_time;
33  gettimeofday(&stop_time, NULL);
34  diff_time.tv_sec = stop_time.tv_sec - start_time.tv_sec;
35  diff_time.tv_usec = stop_time.tv_usec - start_time.tv_usec;
36  return (diff_time.tv_sec*1000.0) + (diff_time.tv_usec/1000.0);
37 }
38 
39 
40 //#ifdef __cplusplus
41 //}
42 //#endif
43 
44 #endif /* __SIMPLETIMER_H */
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
simpletimer_start
struct timeval simpletimer_start(void)
Definition: DataQuality/HanConfigGenerator/src/simpletimer.h:23
simpletimer_stop
double simpletimer_stop(const struct timeval &start_time)
Definition: DataQuality/HanConfigGenerator/src/simpletimer.h:29