]> git.ipfire.org Git - thirdparty/squid.git/blob - src/sbuf/DetailedStats.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / sbuf / DetailedStats.cc
1 /*
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #include "squid.h"
10 #include "sbuf/DetailedStats.h"
11 #include "StatHist.h"
12
13 /*
14 * Implementation note: the purpose of this construct is to avoid adding
15 * external dependencies to the SBuf code
16 */
17
18 static StatHist *
19 newStatHist() {
20 StatHist *stats = new StatHist;
21 stats->logInit(100, 30.0, 128000.0);
22 return stats;
23 }
24
25 StatHist &
26 collectSBufDestructTimeStats()
27 {
28 static StatHist *stats = newStatHist();
29 return *stats;
30 }
31
32 StatHist &
33 collectMemBlobDestructTimeStats()
34 {
35 static StatHist *stats = newStatHist();
36 return *stats;
37 }
38
39 void
40 recordSBufSizeAtDestruct(SBuf::size_type sz)
41 {
42 collectSBufDestructTimeStats().count(static_cast<double>(sz));
43 }
44
45 void
46 recordMemBlobSizeAtDestruct(SBuf::size_type sz)
47 {
48 collectMemBlobDestructTimeStats().count(static_cast<double>(sz));
49 }
50