MySQL 8.3.0
Source Code Documentation
my_rdtsc.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2023, 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*/
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 /** Characteristics of the thread cpu timer. */
65};
66
68
69/**
70 A cycle timer.
71 @return the current timer value, in cycles.
72*/
74
75/**
76 A namoseconds timer.
77 @return the current timer value, in nanoseconds.
78*/
80
81/**
82 A microseconds timer.
83 @return the current timer value, in microseconds.
84*/
86
87/**
88 A millisecond timer.
89 @return the current timer value, in milliseconds.
90*/
92
93/**
94 A ticks timer.
95 @return the current timer value, in ticks.
96*/
98
99/**
100 A THREAD CPU timer.
101 @return the current timer value, in thread cpu.
102*/
104
105/**
106 Timer initialization function.
107 @param [out] mti the timer characteristics.
108*/
110
111#define MY_TIMER_ROUTINE_ASM_X86 1
112#define MY_TIMER_ROUTINE_ASM_X86_64 2
113/* #define MY_TIMER_ROUTINE_RDTSCLL 3 - No longer used */
114/* #define MY_TIMER_ROUTINE_ASM_X86_WIN 4 - No longer used */
115#define MY_TIMER_ROUTINE_RDTSC 5
116#define MY_TIMER_ROUTINE_ASM_IA64 6
117#define MY_TIMER_ROUTINE_ASM_PPC 7
118/* #define MY_TIMER_ROUTINE_SGI_CYCLE 8 - No longer used */
119#define MY_TIMER_ROUTINE_GETHRTIME 9
120/* #define MY_TIMER_ROUTINE_READ_REAL_TIME 10 - No longer used */
121#define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
122#define MY_TIMER_ROUTINE_NXGETTIME 12
123#define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
124#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
125#define MY_TIMER_ROUTINE_GETTICKCOUNT 15
126/* #define MY_TIMER_ROUTINE_TIME 16 - No longer used */
127#define MY_TIMER_ROUTINE_TIMES 17
128/* #define MY_TIMER_ROUTINE_FTIME 18 - No longer used */
129#define MY_TIMER_ROUTINE_ASM_PPC64 19
130/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20 - No longer used */
131/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21 - No longer used */
132/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22 - No longer used */
133#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
134/* #define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24 - No longer used */
135#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
136#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
137/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27 - No longer used */
138#define MY_TIMER_ROUTINE_ASM_AARCH64 28
139#define MY_TIMER_ROUTINE_GET_THREAD_TIMES 29
140#define MY_TIMER_ROUTINE_ASM_S390X 30
141
142#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:225
ulonglong my_timer_ticks(void)
A ticks timer.
Definition: my_rdtsc.cc:301
ulonglong my_timer_cycles(void)
A cycle timer.
Definition: my_rdtsc.cc:97
void my_timer_init(MY_TIMER_INFO *mti)
Timer initialization function.
Definition: my_rdtsc.cc:476
ulonglong my_timer_milliseconds(void)
A millisecond timer.
Definition: my_rdtsc.cc:264
ulonglong my_timer_thread_cpu(void)
A THREAD CPU timer.
Definition: my_rdtsc.cc:318
ulonglong my_timer_nanoseconds(void)
A namoseconds timer.
Definition: my_rdtsc.cc:193
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 thread_cpu
Characteristics of the thread cpu timer.
Definition: my_rdtsc.h:64
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