iipsrv  1.1
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
Timer.h
1 // Timer class
2 
3 /* IIP fcgi server module
4 
5  Copyright (C) 2005-2013 Ruven Pillay.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21 
22 
23 #ifndef _TIMER_H
24 #define _TIMER_H
25 
26 
27 #ifdef HAVE_SYS_TIME_H
28 #include <sys/time.h>
29 #endif
30 
31 
32 #ifdef WIN32
33 #include "../windows/Time.h"
34 #endif
35 
36 
38 
39 class Timer {
40 
41 
42  private:
43 
45  struct timeval tv;
46 
48  struct timezone tz;
49 
51  long start_t;
52 
54  long start_u;
55 
56 
57  public:
58 
60  Timer() {;};
61 
62 
64 
65  void start() {
66  tz.tz_minuteswest = 0;
67  if( gettimeofday( &tv, NULL ) == 0 ){
68  start_t = tv.tv_sec;
69  start_u = tv.tv_usec;
70  }
71  else start_t = start_u = 0;
72  }
73 
74 
76  long getTime() {
77  if( gettimeofday( &tv, NULL ) == 0 ) return (tv.tv_sec - start_t) * 1000000 + (tv.tv_usec - start_u);
78  else return 0;
79  }
80 
81 
82 };
83 
84 
85 
86 #endif
87 
Timer()
Constructor.
Definition: Timer.h:60
long getTime()
Return time since we were initialised in microseconds.
Definition: Timer.h:76
void start()
Set our time.
Definition: Timer.h:65
Simple Timer class to allow us to time our responses.
Definition: Timer.h:39