MySQL 8.4.3
Source Code Documentation
my_rdtsc.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file include/my_rdtsc.h
26 Multi-platform timer code.
27*/
28
29#ifndef MY_RDTSC_H
30#define MY_RDTSC_H
31
32#include "my_inttypes.h"
33#include "my_macros.h"
34
35/**
36 Characteristics of a timer.
37*/
39 /** Routine used for the timer. */
41 /** Overhead of the timer. */
43 /** Frequency of the timer. */
45 /** Resolution of the timer. */
47};
48
49/**
50 Characteristics of all the supported timers.
51 @sa my_timer_init().
52*/
54 /** Characteristics of the cycle timer. */
56 /** Characteristics of the nanosecond timer. */
58 /** Characteristics of the microsecond timer. */
60 /** Characteristics of the millisecond timer. */
62 /** Characteristics of the tick timer. */
64 /** Characteristics of the thread cpu timer. */
66};
67
69
70/**
71 A cycle timer.
72 @return the current timer value, in cycles.
73*/
75
76/**
77 A namoseconds timer.
78 @return the current timer value, in nanoseconds.
79*/
81
82/**
83 A microseconds timer.
84 @return the current timer value, in microseconds.
85*/
87
88/**
89 A millisecond timer.
90 @return the current timer value, in milliseconds.
91*/
93
94/**
95 A ticks timer.
96 @return the current timer value, in ticks.
97*/
99
100/**
101 A THREAD CPU timer.
102 @return the current timer value, in thread cpu.
103*/
105
106/**
107 Timer initialization function.
108 @param [out] mti the timer characteristics.
109*/
111
112#define MY_TIMER_ROUTINE_ASM_X86 1
113#define MY_TIMER_ROUTINE_ASM_X86_64 2
114/* #define MY_TIMER_ROUTINE_RDTSCLL 3 - No longer used */
115/* #define MY_TIMER_ROUTINE_ASM_X86_WIN 4 - No longer used */
116#define MY_TIMER_ROUTINE_RDTSC 5
117#define MY_TIMER_ROUTINE_ASM_IA64 6
118#define MY_TIMER_ROUTINE_ASM_PPC 7
119/* #define MY_TIMER_ROUTINE_SGI_CYCLE 8 - No longer used */
120#define MY_TIMER_ROUTINE_GETHRTIME 9
121/* #define MY_TIMER_ROUTINE_READ_REAL_TIME 10 - No longer used */
122#define MY_TIMER_ROUTINE_CLOCK_GETTIME 11
123#define MY_TIMER_ROUTINE_NXGETTIME 12
124#define MY_TIMER_ROUTINE_GETTIMEOFDAY 13
125#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
126#define MY_TIMER_ROUTINE_GETTICKCOUNT 15
127/* #define MY_TIMER_ROUTINE_TIME 16 - No longer used */
128#define MY_TIMER_ROUTINE_TIMES 17
129/* #define MY_TIMER_ROUTINE_FTIME 18 - No longer used */
130#define MY_TIMER_ROUTINE_ASM_PPC64 19
131/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64 20 - No longer used */
132/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32 21 - No longer used */
133/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22 - No longer used */
134#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
135/* #define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24 - No longer used */
136#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
137#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
138/* #define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64 27 - No longer used */
139#define MY_TIMER_ROUTINE_ASM_AARCH64 28
140#define MY_TIMER_ROUTINE_GET_THREAD_TIMES 29
141#define MY_TIMER_ROUTINE_ASM_S390X 30
142
143#endif
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Some common macros.
ulonglong my_timer_microseconds(void)
A microseconds timer.
Definition: my_rdtsc.cc:226
ulonglong my_timer_ticks(void)
A ticks timer.
Definition: my_rdtsc.cc:302
ulonglong my_timer_cycles(void)
A cycle timer.
Definition: my_rdtsc.cc:98
void my_timer_init(MY_TIMER_INFO *mti)
Timer initialization function.
Definition: my_rdtsc.cc:477
ulonglong my_timer_milliseconds(void)
A millisecond timer.
Definition: my_rdtsc.cc:265
ulonglong my_timer_thread_cpu(void)
A THREAD CPU timer.
Definition: my_rdtsc.cc:319
ulonglong my_timer_nanoseconds(void)
A namoseconds timer.
Definition: my_rdtsc.cc:194
Characteristics of all the supported timers.
Definition: my_rdtsc.h:53
struct my_timer_unit_info microseconds
Characteristics of the microsecond timer.
Definition: my_rdtsc.h:59
struct my_timer_unit_info cycles
Characteristics of the cycle timer.
Definition: my_rdtsc.h:55
struct my_timer_unit_info thread_cpu
Characteristics of the thread cpu timer.
Definition: my_rdtsc.h:65
struct my_timer_unit_info ticks
Characteristics of the tick timer.
Definition: my_rdtsc.h:63
struct my_timer_unit_info nanoseconds
Characteristics of the nanosecond timer.
Definition: my_rdtsc.h:57
struct my_timer_unit_info milliseconds
Characteristics of the millisecond timer.
Definition: my_rdtsc.h:61
Characteristics of a timer.
Definition: my_rdtsc.h:38
ulonglong resolution
Resolution of the timer.
Definition: my_rdtsc.h:46
ulonglong overhead
Overhead of the timer.
Definition: my_rdtsc.h:42
ulonglong frequency
Frequency of the timer.
Definition: my_rdtsc.h:44
ulonglong routine
Routine used for the timer.
Definition: my_rdtsc.h:40