1 /* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
20 @file mysql/psi/mysql_stage.h
21 Instrumentation helpers for stages.
24 #include "mysql/psi/psi.h"
26 #ifndef PSI_STAGE_CALL
27 #define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
31 @defgroup Stage_instrumentation Stage Instrumentation
32 @ingroup Instrumentation_interface
37 @def mysql_stage_register(P1, P2, P3)
40 #ifdef HAVE_PSI_STAGE_INTERFACE
41 #define mysql_stage_register(P1, P2, P3) \
42 inline_mysql_stage_register(P1, P2, P3)
44 #define mysql_stage_register(P1, P2, P3) \
50 Set the current stage.
51 Use this API when the file and line
52 is passed from the caller.
53 @param K the stage key
54 @param F the source file name
55 @param L the source file line
56 @return the current stage progress
58 #ifdef HAVE_PSI_STAGE_INTERFACE
59 #define MYSQL_SET_STAGE(K, F, L) \
60 inline_mysql_set_stage(K, F, L)
62 #define MYSQL_SET_STAGE(K, F, L) \
68 Set the current stage.
69 @param K the stage key
70 @return the current stage progress
72 #ifdef HAVE_PSI_STAGE_INTERFACE
73 #define mysql_set_stage(K) \
74 inline_mysql_set_stage(K, __FILE__, __LINE__)
76 #define mysql_set_stage(K) \
84 #ifdef HAVE_PSI_STAGE_INTERFACE
85 #define mysql_end_stage \
86 inline_mysql_end_stage
88 #define mysql_end_stage \
92 #ifdef HAVE_PSI_STAGE_INTERFACE
93 static inline void inline_mysql_stage_register(
94 const char *category, PSI_stage_info **info, int count)
96 PSI_STAGE_CALL(register_stage)(category, info, count);
100 #ifdef HAVE_PSI_STAGE_INTERFACE
101 static inline PSI_stage_progress*
102 inline_mysql_set_stage(PSI_stage_key key,
103 const char *src_file, int src_line)
105 return PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
109 #ifdef HAVE_PSI_STAGE_INTERFACE
111 inline_mysql_end_stage()
113 PSI_STAGE_CALL(end_stage)();
117 #ifdef HAVE_PSI_STAGE_INTERFACE
118 #define mysql_stage_set_work_completed(P1, P2) \
119 inline_mysql_stage_set_work_completed(P1, P2)
121 #define mysql_stage_get_work_completed(P1) \
122 inline_mysql_stage_get_work_completed(P1)
124 #define mysql_stage_set_work_completed(P1, P2) \
127 #define mysql_stage_get_work_completed(P1) \
131 #ifdef HAVE_PSI_STAGE_INTERFACE
132 #define mysql_stage_inc_work_completed(P1, P2) \
133 inline_mysql_stage_inc_work_completed(P1, P2)
135 #define mysql_stage_inc_work_completed(P1, P2) \
139 #ifdef HAVE_PSI_STAGE_INTERFACE
140 #define mysql_stage_set_work_estimated(P1, P2) \
141 inline_mysql_stage_set_work_estimated(P1, P2)
143 #define mysql_stage_get_work_estimated(P1) \
144 inline_mysql_stage_get_work_estimated(P1)
146 #define mysql_stage_set_work_estimated(P1, P2) \
149 #define mysql_stage_get_work_estimated(P1) \
153 #ifdef HAVE_PSI_STAGE_INTERFACE
155 inline_mysql_stage_set_work_completed(PSI_stage_progress *progress,
158 if (progress != NULL)
159 progress->m_work_completed= val;
162 static inline ulonglong
163 inline_mysql_stage_get_work_completed(PSI_stage_progress *progress)
165 return progress->m_work_completed;
169 #ifdef HAVE_PSI_STAGE_INTERFACE
171 inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress,
174 if (progress != NULL)
175 progress->m_work_completed+= val;
179 #ifdef HAVE_PSI_STAGE_INTERFACE
181 inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress,
184 if (progress != NULL)
185 progress->m_work_estimated= val;
188 static inline ulonglong
189 inline_mysql_stage_get_work_estimated(PSI_stage_progress *progress)
191 return progress->m_work_estimated;
195 /** @} (end of group Stage_instrumentation) */