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 Foundation,
21   51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 #ifndef TABLE_PERFORMANCE_TIMERS_H
24 #define TABLE_PERFORMANCE_TIMERS_H
25 
26 /**
27   @file storage/perfschema/table_performance_timers.h
28   Table PERFORMANCE_TIMERS (declarations).
29 */
30 
31 #include <my_rdtsc.h>
32 #include "pfs_column_types.h"
33 #include "pfs_engine_table.h"
34 
35 /**
36   @addtogroup Performance_schema_tables
37   @{
38 */
39 
40 /** A row of PERFORMANCE_SCHEMA.PERFORMANCE_TIMERS. */
41 struct row_performance_timers
42 {
43   /** Column TIMER_NAME. */
44   enum_timer_name m_timer_name;
45   /**
46     Columns ROUTINE (not displayed), TIMER_OVERHEAD,
47     TIMER_FREQUENCY, TIMER_RESOLUTION.
48   */
49   struct my_timer_unit_info m_info;
50 };
51 
52 /** Table PERFORMANCE_SCHEMA.PERFORMANCE_TIMERS. */
53 class table_performance_timers : public PFS_engine_table
54 {
55 public:
56   /** Table share. */
57   static PFS_engine_table_share m_share;
58   static PFS_engine_table* create();
59   static ha_rows get_row_count();
60 
61   virtual int rnd_next();
62   virtual int rnd_pos(const void *pos);
63   virtual void reset_position(void);
64 
65 protected:
66   virtual int read_row_values(TABLE *table,
67                               unsigned char *buf,
68                               Field **fields,
69                               bool read_all);
70 
71 protected:
72   table_performance_timers();
73 
74 public:
~table_performance_timers()75   ~table_performance_timers()
76   {}
77 
78 private:
79   /** Table share lock. */
80   static THR_LOCK m_table_lock;
81   /** Fields definition. */
82   static TABLE_FIELD_DEF m_field_def;
83 
84   /** Current row. */
85   row_performance_timers *m_row;
86   /** Current position. */
87   PFS_simple_index m_pos;
88   /** Next position. */
89   PFS_simple_index m_next_pos;
90   row_performance_timers m_data[COUNT_TIMER_NAME];
91 };
92 
93 /** @} */
94 #endif
95