1/* Copyright (c) 2010, 2015, 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
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16
17#include "my_global.h"
18#include "my_pthread.h"
19#include "pfs_con_slice.h"
20#include "pfs_stat.h"
21#include "pfs_global.h"
22#include "pfs_instr_class.h"
23
24/**
25 @file storage/perfschema/pfs_con_slice.cc
26 Performance schema connection slice (implementation).
27*/
28
29/**
30 @addtogroup Performance_schema_buffers
31 @{
32*/
33
34PFS_single_stat *
35PFS_connection_slice::alloc_waits_slice(uint sizing)
36{
37 PFS_single_stat *slice= NULL;
38 uint index;
39
40 if (sizing > 0)
41 {
42 slice= PFS_MALLOC_ARRAY(sizing, sizeof(PFS_single_stat), PFS_single_stat,
43 MYF(MY_ZEROFILL));
44 if (unlikely(slice == NULL))
45 return NULL;
46
47 for (index= 0; index < sizing; index++)
48 slice[index].reset();
49 }
50
51 return slice;
52}
53
54PFS_stage_stat *
55PFS_connection_slice::alloc_stages_slice(uint sizing)
56{
57 PFS_stage_stat *slice= NULL;
58 uint index;
59
60 if (sizing > 0)
61 {
62 slice= PFS_MALLOC_ARRAY(sizing, sizeof(PFS_stage_stat), PFS_stage_stat,
63 MYF(MY_ZEROFILL));
64 if (unlikely(slice == NULL))
65 return NULL;
66
67 for (index= 0; index < sizing; index++)
68 slice[index].reset();
69 }
70
71 return slice;
72}
73
74PFS_statement_stat *
75PFS_connection_slice::alloc_statements_slice(uint sizing)
76{
77 PFS_statement_stat *slice= NULL;
78 uint index;
79
80 if (sizing > 0)
81 {
82 slice= PFS_MALLOC_ARRAY(sizing, sizeof(PFS_statement_stat), PFS_statement_stat,
83 MYF(MY_ZEROFILL));
84 if (unlikely(slice == NULL))
85 return NULL;
86
87 for (index= 0; index < sizing; index++)
88 slice[index].reset();
89 }
90
91 return slice;
92}
93
94void PFS_connection_slice::reset_waits_stats()
95{
96 PFS_single_stat *stat= m_instr_class_waits_stats;
97 PFS_single_stat *stat_last= stat + wait_class_max;
98 for ( ; stat < stat_last; stat++)
99 stat->reset();
100}
101
102void PFS_connection_slice::reset_stages_stats()
103{
104 PFS_stage_stat *stat= m_instr_class_stages_stats;
105 PFS_stage_stat *stat_last= stat + stage_class_max;
106 for ( ; stat < stat_last; stat++)
107 stat->reset();
108}
109
110void PFS_connection_slice::reset_statements_stats()
111{
112 PFS_statement_stat *stat= m_instr_class_statements_stats;
113 PFS_statement_stat *stat_last= stat + statement_class_max;
114 for ( ; stat < stat_last; stat++)
115 stat->reset();
116}
117
118/** @} */
119
120