Debian Codegraph @

src/Libpfs/utils/msec_timer.h

raw
1 /**
2 * @brief Milliseconds Timer
3 *
4 * ----------------------------------------------------------------------
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * ----------------------------------------------------------------------
19 *
20 * http://msdn.microsoft.com/en-us/library/ms644904%28v=VS.85%29.aspx
21 *
22 * @author Davide Anastasia, <[email protected]>
23 *
24 */
25
26 #ifndef MSEC_TIMER_H
27 #define MSEC_TIMER_H
28
29 #if defined(_WIN32) || defined(__CYGWIN__)
30 #define WIN_TIMER
31 #endif
32
33 /*
34 * this define enables the timing profile
35 * You should comment this define if you want to disable this feature
36 */
37 #ifndef NDEBUG
38 #define TIMER_PROFILING
39 #endif
40
41 #include <stdio.h>
42 //#include <iostream>
43
44 // TIMER -----
45 #ifdef WIN_TIMER
46 #define _WINSOCKAPI_ // stops windows.h including winsock.h
47 #include <windows.h>
48 #elif defined(__APPLE__)
49 #include <mach/mach_time.h>
50 #include <stdint.h>
51 #else
52 //#include <ctime>
53 #include <sys/time.h>
54 #endif
55
56 class msec_timer {
57 private:
58 #ifdef WIN_TIMER
59 LARGE_INTEGER start_t;
60 LARGE_INTEGER stop_t;
61 double wrk_time;
62 LARGE_INTEGER freq;
63 #elif defined(__APPLE__)
64 uint64_t start_t;
65 uint64_t stop_t;
66 uint64_t wrk_time;
67 double conversion;
68 #else
69 timeval start_t;
70 timeval stop_t;
71 double wrk_time;
72 #endif
73
74 public:
75 msec_timer();
76 ~msec_timer();
77 void start();
78 void stop();
79 void update();
80 void stop_and_update();
81 void reset();
82 double get_time();
83
84 void get_timer_type();
85 };
86
87 double convert_to_gigaflops(double, double);
88
89 #endif // MSEC_TIMER_H