MySQL  8.0.27
Source Code Documentation
my_rdtsc.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 /**
24  @file include/my_rdtsc.h
25  Multi-platform timer code.
26 */
27 
28 #ifndef MY_RDTSC_H
29 #define MY_RDTSC_H
30 
31 #include "my_inttypes.h"
32 #include "my_macros.h"
33 
34 /**
35  Characteristics of a timer.
36 */
38  /** Routine used for the timer. */
40  /** Overhead of the timer. */
42  /** Frequency of the timer. */
44  /** Resolution of the timer. */
46 };
47 
48 /**
49  Characteristics of all the supported timers.
50  @sa my_timer_init().
51 */
52 struct my_timer_info {
53  /** Characteristics of the cycle timer. */
55  /** Characteristics of the nanosecond timer. */
57  /** Characteristics of the microsecond timer. */
59  /** Characteristics of the millisecond timer. */
61  /** Characteristics of the tick timer. */
63 };
64 
65 typedef struct my_timer_info MY_TIMER_INFO;
66 
67 /**
68  A cycle timer.
69  @return the current timer value, in cycles.
70 */
72 
73 /**
74  A namoseconds timer.
75  @return the current timer value, in nanoseconds.
76 */
78 
79 /**
80  A microseconds timer.
81  @return the current timer value, in microseconds.
82 */
84 
85 /**
86  A millisecond timer.
87  @return the current timer value, in milliseconds.
88 */
90 
91 /**
92  A ticks timer.
93  @return the current timer value, in ticks.
94 */
96 
97 /**
98  Timer initialization function.
99  @param [out] mti the timer characteristics.
100 */
101 void my_timer_init(MY_TIMER_INFO *mti);
102 
103 #define MY_TIMER_ROUTINE_ASM_X86 1
104 #define MY_TIMER_ROUTINE_ASM_X86_64 2
105 /* #define MY_TIMER_ROUTINE_RDTSCLL 3 - No longer used */
106 /* #define MY_TIMER_ROUTINE_ASM_X86_WIN 4 - No longer used */
107 #define MY_TIMER_ROUTINE_RDTSC 5
108 #define MY_TIMER_ROUTINE_ASM_IA64 6
109 #define MY_TIMER_ROUTINE_ASM_PPC 7
110 /* #define MY_TIMER_ROUTINE_SGI_CYCLE 8 - No longer used */
111 #define MY_TIMER_ROUTINE_GETHRTIME 9
112 /* #define MY_TIMER_ROUTINE_READ_REAL_TIME 10 - No longer used */
113 #define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
114 #define MY_TIMER_ROUTINE_NXGETTIME 12
115 #define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
116 #define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
117 #define MY_TIMER_ROUTINE_GETTICKCOUNT 15
118 /* #define MY_TIMER_ROUTINE_TIME 16 - No longer used */
119 #define MY_TIMER_ROUTINE_TIMES 17
120 /* #define MY_TIMER_ROUTINE_FTIME 18 - No longer used */
121 #define MY_TIMER_ROUTINE_ASM_PPC64 19
122 /* #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20 - No longer used */
123 /* #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21 - No longer used */
124 /* #define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22 - No longer used */
125 #define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
126 /* #define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24 - No longer used */
127 #define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
128 #define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
129 /* #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27 - No longer used */
130 #define MY_TIMER_ROUTINE_ASM_AARCH64 28
131 
132 #endif
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Some common macros.
ulonglong my_timer_microseconds(void)
A microseconds timer.
Definition: my_rdtsc.cc:217
ulonglong my_timer_ticks(void)
A ticks timer.
Definition: my_rdtsc.cc:293
ulonglong my_timer_cycles(void)
A cycle timer.
Definition: my_rdtsc.cc:95
void my_timer_init(MY_TIMER_INFO *mti)
Timer initialization function.
Definition: my_rdtsc.cc:431
ulonglong my_timer_milliseconds(void)
A millisecond timer.
Definition: my_rdtsc.cc:256
ulonglong my_timer_nanoseconds(void)
A namoseconds timer.
Definition: my_rdtsc.cc:185
Characteristics of all the supported timers.
Definition: my_rdtsc.h:52
struct my_timer_unit_info microseconds
Characteristics of the microsecond timer.
Definition: my_rdtsc.h:58
struct my_timer_unit_info cycles
Characteristics of the cycle timer.
Definition: my_rdtsc.h:54
struct my_timer_unit_info ticks
Characteristics of the tick timer.
Definition: my_rdtsc.h:62
struct my_timer_unit_info nanoseconds
Characteristics of the nanosecond timer.
Definition: my_rdtsc.h:56
struct my_timer_unit_info milliseconds
Characteristics of the millisecond timer.
Definition: my_rdtsc.h:60
Characteristics of a timer.
Definition: my_rdtsc.h:37
ulonglong resolution
Resolution of the timer.
Definition: my_rdtsc.h:45
ulonglong overhead
Overhead of the timer.
Definition: my_rdtsc.h:41
ulonglong frequency
Frequency of the timer.
Definition: my_rdtsc.h:43
ulonglong routine
Routine used for the timer.
Definition: my_rdtsc.h:39