D.S

dev.mysql.com

MySQL: storage/perfschema/pfs_stat.h Source File

MySQL: storage/perfschema/pfs_stat.h Source File MySQL  8.0.0 Source Code Documentation Main Page Related Pages Modules Namespaces Classes Files File List File Members pfs_stat.h Go to the documentation of this file. 1 /* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. 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 as published by 5  the Free Software Foundation; version 2 of the License. 6  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. 11  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 Foundation, 14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 15  16 #ifndef PFS_STAT_H 17 #define PFS_STAT_H 18  19 #include <algorithm> 20 #include " sql_const.h " 21 /* memcpy */ 22 #include "string.h" 23  24 #include " pfs_error.h " 25 #include " pfs_global.h " 26  27 struct PFS_builtin_memory_class ; 28  29 /** 30  @file storage/perfschema/pfs_stat.h 31  Statistics (declarations). 32 */ 33  34 /** 35  @addtogroup performance_schema_buffers 36  @{ 37 */ 38  39 /** Single statistic. */ 40  struct PFS_single_stat 41 { 42  /** Count of values. */ 43   ulonglong m_count ; 44  /** Sum of values. */ 45   ulonglong m_sum ; 46  /** Minimum value. */ 47   ulonglong m_min ; 48  /** Maximum value. */ 49   ulonglong m_max ; 50  51   PFS_single_stat () 52  { 53  m_count= 0; 54  m_sum= 0; 55  m_min= ULLONG_MAX; 56  m_max= 0; 57  } 58  59   inline void reset (void) 60  { 61  m_count= 0; 62  m_sum= 0; 63  m_min= ULLONG_MAX; 64  m_max= 0; 65  } 66  67   inline bool has_timed_stats () const 68  { 69  return (m_min <= m_max); 70  } 71  72   inline void aggregate (const PFS_single_stat *stat) 73  { 74  if (stat-> m_count != 0) 75  { 76  m_count+= stat-> m_count ; 77  m_sum+= stat-> m_sum ; 78  if ( unlikely (m_min > stat-> m_min )) 79  m_min= stat-> m_min ; 80  if ( unlikely (m_max < stat->m_max)) 81  m_max= stat-> m_max ; 82  } 83  } 84  85   inline void aggregate_no_check (const PFS_single_stat *stat) 86  { 87  m_count+= stat-> m_count ; 88  m_sum+= stat-> m_sum ; 89  if ( unlikely (m_min > stat-> m_min )) 90  m_min= stat-> m_min ; 91  if ( unlikely (m_max < stat->m_max)) 92  m_max= stat-> m_max ; 93  } 94  95   inline void aggregate_counted () 96  { 97  m_count++; 98  } 99  100   inline void aggregate_counted ( ulonglong count ) 101  { 102  m_count+= count ; 103  } 104  105   inline void aggregate_value ( ulonglong value) 106  { 107  m_count++; 108  m_sum+= value; 109  if ( unlikely (m_min > value)) 110  m_min= value; 111  if ( unlikely (m_max < value)) 112  m_max= value; 113  } 114  115   inline void aggregate_many_value ( ulonglong value, ulonglong count ) 116  { 117  m_count+= count ; 118  m_sum+= value; 119  if ( unlikely (m_min > value)) 120  m_min= value; 121  if ( unlikely (m_max < value)) 122  m_max= value; 123  } 124 }; 125  126 /** Combined statistic. */ 127  struct PFS_byte_stat : public PFS_single_stat 128 { 129  /** Byte count statistics */ 130   ulonglong m_bytes ; 131  132  /** Aggregate wait stats, event count and byte count */ 133   inline void aggregate (const PFS_byte_stat *stat) 134  { 135  if (stat-> m_count != 0) 136  { 137  PFS_single_stat::aggregate_no_check (stat); 138  m_bytes+= stat-> m_bytes ; 139  } 140  } 141  142  /** Aggregate wait stats, event count and byte count */ 143   inline void aggregate_no_check (const PFS_byte_stat *stat) 144  { 145  PFS_single_stat::aggregate_no_check (stat); 146  m_bytes+= stat-> m_bytes ; 147  } 148  149  /** Aggregate individual wait time, event count and byte count */ 150   inline void aggregate ( ulonglong wait, ulonglong bytes) 151  { 152  aggregate_value (wait); 153  m_bytes+= bytes; 154  } 155  156  /** Aggregate wait stats and event count */ 157   inline void aggregate_waits (const PFS_byte_stat *stat) 158  { 159  PFS_single_stat::aggregate (stat); 160  } 161  162  /** Aggregate event count and byte count */ 163   inline void aggregate_counted () 164  { 165  PFS_single_stat::aggregate_counted (); 166  } 167  168  /** Aggregate event count and byte count */ 169   inline void aggregate_counted ( ulonglong bytes) 170  { 171  PFS_single_stat::aggregate_counted (); 172  m_bytes+= bytes; 173  } 174  175   PFS_byte_stat () 176  { 177  reset (); 178  } 179  180   inline void reset (void) 181  { 182  PFS_single_stat::reset (); 183  m_bytes= 0; 184  } 185 }; 186  187 /** Statistics for mutex usage. */ 188  struct PFS_mutex_stat 189 { 190  /** Wait statistics. */ 191   PFS_single_stat m_wait_stat ; 192 #ifdef PFS_LATER 193  /** 194  Lock statistics. 195  This statistic is not exposed in user visible tables yet. 196  */ 197  PFS_single_stat m_lock_stat; 198 #endif 199  200