]>
Commit | Line | Data |
---|---|---|
b268925c | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
b268925c AJ |
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 | #ifndef SQUID_SBUF_STATS_H | |
10 | #define SQUID_SBUF_STATS_H | |
11 | ||
12 | #include <iosfwd> | |
13 | ||
14 | /** | |
15 | * Container for various SBuf class-wide statistics. | |
16 | * | |
17 | * The stats are not completely accurate; they're mostly meant to | |
18 | * understand whether Squid is leaking resources | |
19 | * and whether SBuf is paying off the expected gains. | |
20 | */ | |
21 | class SBufStats | |
22 | { | |
23 | public: | |
b268925c AJ |
24 | ///Dump statistics to an ostream. |
25 | std::ostream& dump(std::ostream &os) const; | |
b268925c AJ |
26 | |
27 | SBufStats& operator +=(const SBufStats&); | |
14610262 | 28 | |
f079ed87 AR |
29 | /// Record the size a SBuf had when it was destructed |
30 | static void RecordSBufSizeAtDestruct(size_t); | |
31 | ||
32 | /// Record the size a MemBlob had when it was destructed | |
33 | static void RecordMemBlobSizeAtDestruct(size_t); | |
34 | ||
14610262 AJ |
35 | public: |
36 | uint64_t alloc = 0; ///<number of calls to SBuf constructors | |
37 | uint64_t allocCopy = 0; ///<number of calls to SBuf copy-constructor | |
38 | uint64_t allocFromCString = 0; ///<number of copy-allocations from c-strings | |
39 | uint64_t assignFast = 0; ///<number of no-copy assignment operations | |
40 | uint64_t clear = 0; ///<number of clear operations | |
41 | uint64_t append = 0; ///<number of append operations | |
42 | uint64_t moves = 0; ///<number of move constructions/assignments | |
43 | uint64_t toStream = 0; ///<number of write operations to ostreams | |
44 | uint64_t setChar = 0; ///<number of calls to setAt | |
45 | uint64_t getChar = 0; ///<number of calls to at() and operator[] | |
46 | uint64_t compareSlow = 0; ///<number of comparison operations requiring data scan | |
47 | uint64_t compareFast = 0; ///<number of comparison operations not requiring data scan | |
48 | uint64_t copyOut = 0; ///<number of data-copies to other forms of buffers | |
49 | uint64_t rawAccess = 0; ///<number of accesses to raw contents | |
50 | uint64_t nulTerminate = 0; ///<number of c_str() terminations | |
51 | uint64_t chop = 0; ///<number of chop operations | |
52 | uint64_t trim = 0; ///<number of trim operations | |
53 | uint64_t find = 0; ///<number of find operations | |
54 | uint64_t caseChange = 0; ///<number of toUpper and toLower operations | |
963caaa7 AR |
55 | uint64_t cowAvoided = 0; ///< number of cow() calls requiring no expensive operations |
56 | uint64_t cowShift = 0; ///< number of cow() calls requiring just a memmove(3) inside an old buffer | |
57 | uint64_t cowJustAlloc = 0; ///< number of cow() calls requiring just a new empty buffer | |
58 | uint64_t cowAllocCopy = 0; ///< number of cow() calls requiring copying into a new buffer | |
14610262 | 59 | uint64_t live = 0; ///<number of currently-allocated SBuf |
f079ed87 AR |
60 | |
61 | /// function for collecting detailed size-related statistics | |
62 | using SizeRecorder = void (*)(size_t); | |
63 | /// collects statistics about SBuf sizes at SBuf destruction time | |
64 | static SizeRecorder SBufSizeAtDestructRecorder; | |
65 | /// collects statistics about MemBlob capacity at MemBlob destruction time | |
66 | static SizeRecorder MemBlobSizeAtDestructRecorder; | |
b268925c AJ |
67 | }; |
68 | ||
69 | #endif /* SQUID_SBUF_STATS_H */ | |
bb7082c2 | 70 |