ddc
ServerStats.h
Go to the documentation of this file.
1 //-*- Mode: C++ -*-
2 //
3 // DDC originally by Alexey Sokirko
4 // Changes and modifications 2011-2018 by Bryan Jurish
5 //
6 // This file is part of DDC.
7 //
8 // DDC is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Lesser General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // DDC is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public License
19 // along with DDC. If not, see <http://www.gnu.org/licenses/>.
20 //
21 #ifndef DDC_SERVER_STATS_H
22 #define DDC_SERVER_STATS_H
23 
24 #include "../CommonLib/ddcTime.h"
25 #include <set>
26 
27 //==============================================================================
28 
30 //#define DDC_SERVER_EMA_DELAYS 60,300,900 /* load-average style: 1,5,15 minutes*/
31 #define DDC_SERVER_EMA_DELAYS 300,900,3600 /* long window: 5,15,60 minutes */
32 
35 {
36  //--------------------------------------------------------------
37  // Counters
38 
40  size_t m_nRequests;
41 
43  size_t m_nQueries;
44 
46  size_t m_nExpand;
47 
49  size_t m_nErrors;
50 
52  size_t m_nSlow;
53 
56 
59 
60  //--------------------------------------------------------------
61  // Constructors etc.
62 
65  : m_nRequests(0), m_nQueries(0), m_nExpand(0), m_nErrors(0), m_nSlow(0), m_qTimes(DDC_SERVER_EMA_DELAYS), m_xTimes(DDC_SERVER_EMA_DELAYS)
66  {};
67 
70  : m_nRequests(x.m_nRequests), m_nQueries(x.m_nQueries), m_nExpand(x.m_nExpand), m_nErrors(x.m_nErrors), m_nSlow(x.m_nSlow), m_qTimes(x.m_qTimes), m_xTimes(x.m_xTimes)
71  {};
72 
74  inline void clear()
75  {
76  m_nRequests = 0;
77  m_nQueries = 0;
78  m_nExpand = 0;
79  m_nErrors = 0;
80  m_nSlow = 0;
81  m_qTimes.reset();
82  m_xTimes.reset();
83  };
84 
85  //--------------------------------------------------------------
86  // Operators
87 
90 
92  inline CDDCServerStats operator+(const CDDCServerStats &x) const
93  { return CDDCServerStats(*this) += x; };
94 };
95 
96 
97 #endif /* DDC_SERVER_STATS_H */
98 
99 /*--- emacs style variables ---
100  * Local Variables:
101  * mode: C++
102  * c-file-style: "ellemtel"
103  * c-basic-offset: 4
104  * tab-width: 8
105  * indent-tabs-mode: nil
106  * End:
107  */
#define DDC_SERVER_EMA_DELAYS
Definition: ServerStats.h:31
Definition: ServerStats.h:34
Definition: ddcTime.h:239
size_t m_nErrors
Definition: ServerStats.h:49
CDDCServerStats operator+(const CDDCServerStats &x) const
Definition: ServerStats.h:92
CDDCServerStats()
Definition: ServerStats.h:64
size_t m_nQueries
Definition: ServerStats.h:43
size_t m_nRequests
Definition: ServerStats.h:40
size_t m_nExpand
Definition: ServerStats.h:46
CDDCServerStats & operator+=(const CDDCServerStats &x)
Definition: ServerStats.cpp:29
void clear()
Definition: ServerStats.h:74
size_t m_nSlow
Definition: ServerStats.h:52
void reset(ValueT val=0)
Definition: ddcTime.cpp:124
DDCTimeAvg m_xTimes
Definition: ServerStats.h:58
CDDCServerStats(const CDDCServerStats &x)
Definition: ServerStats.h:69
DDCTimeAvg m_qTimes
Definition: ServerStats.h:55