1
/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
rdtsc3 -- multi-platform timer code
18
pgulutzan@mysql.com, 2005-08-29
30
#define C_MODE_START G_BEGIN_DECLS
31
#define C_MODE_END G_END_DECLS
32
typedef guint64 ulonglong;
36
typedef ulong_t ulong;
37
#else /* HAVE_ULONG_T */
38
typedef guint32 ulong;
39
#endif /* HAVE_ULONG_T */
40
#endif /* HAVE_ULONG */
43
This structure contains the characteristics of all the supported timers.
48
/** Routine used for the cycle timer. */
49
ulonglong cycles_routine;
50
/** Overhead of the cycle timer. */
51
ulonglong cycles_overhead;
52
/** Frequency of the cycle timer. */
53
ulonglong cycles_frequency;
54
/** Resolution of the cycle timer. */
55
ulonglong cycles_resolution;
56
/** Routine used for the nanosecond timer. */
57
ulonglong nanoseconds_routine;
58
/** Overhead of the nanosecond timer. */
59
ulonglong nanoseconds_overhead;
60
/** Frequency of the nanosecond timer. */
61
ulonglong nanoseconds_frequency;
62
/** Resolution of the nanosecond timer. */
63
ulonglong nanoseconds_resolution;
64
/** Routine used for the microsecond timer. */
65
ulonglong microseconds_routine;
66
/** Overhead of the microsecond timer. */
67
ulonglong microseconds_overhead;
68
/** Frequency of the microsecond timer. */
69
ulonglong microseconds_frequency;
70
/** Resolution of the microsecond timer. */
71
ulonglong microseconds_resolution;
72
/** Routine used for the millisecond timer. */
73
ulonglong milliseconds_routine;
74
/** Overhead of the millisecond timer. */
75
ulonglong milliseconds_overhead;
76
/** Frequency of the millisecond timer. */
77
ulonglong milliseconds_frequency;
78
/** Resolution of the millisecond timer. */
79
ulonglong milliseconds_resolution;
80
/** Routine used for the tick timer. */
81
ulonglong ticks_routine;
82
/** Overhead of the tick timer. */
83
ulonglong ticks_overhead;
84
/** Frequency of the tick timer. */
85
ulonglong ticks_frequency;
86
/** Resolution of the tick timer. */
87
ulonglong ticks_resolution;
90
typedef struct my_timer_info MY_TIMER_INFO;
96
@return the current timer value, in cycles.
98
ulonglong my_timer_cycles(void);
102
@return the current timer value, in nanoseconds.
104
ulonglong my_timer_nanoseconds(void);
107
A microseconds timer.
108
@return the current timer value, in microseconds.
110
ulonglong my_timer_microseconds(void);
114
@return the current timer value, in milliseconds.
116
ulonglong my_timer_milliseconds(void);
120
@return the current timer value, in ticks.
122
ulonglong my_timer_ticks(void);
125
Timer initialization function.
126
@param [out] mti the timer characteristics.
128
void my_timer_init(MY_TIMER_INFO *mti);
132
#define MY_TIMER_ROUTINE_ASM_X86 1
133
#define MY_TIMER_ROUTINE_ASM_X86_64 2
134
#define MY_TIMER_ROUTINE_RDTSCLL 3
135
#define MY_TIMER_ROUTINE_ASM_X86_WIN 4
136
#define MY_TIMER_ROUTINE_RDTSC 5
137
#define MY_TIMER_ROUTINE_ASM_IA64 6
138
#define MY_TIMER_ROUTINE_ASM_PPC 7
139
#define MY_TIMER_ROUTINE_SGI_CYCLE 8
140
#define MY_TIMER_ROUTINE_GETHRTIME 9
141
#define MY_TIMER_ROUTINE_READ_REAL_TIME 10
142
#define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
143
#define MY_TIMER_ROUTINE_NXGETTIME 12
144
#define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
145
#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
146
#define MY_TIMER_ROUTINE_GETTICKCOUNT 15
147
#define MY_TIMER_ROUTINE_TIME 16
148
#define MY_TIMER_ROUTINE_TIMES 17
149
#define MY_TIMER_ROUTINE_FTIME 18
150
#define MY_TIMER_ROUTINE_ASM_PPC64 19
151
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20
152
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21
153
#define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22
154
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
155
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24
156
#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
157
#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
158
#define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27