Stats.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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/MemBlob.h"
11#include "sbuf/SBuf.h"
12#include "sbuf/Stats.h"
13
14#include <iostream>
15
18
19void
21{
24}
25
26void
28{
31}
32
35{
36 alloc += ss.alloc;
37 allocCopy += ss.allocCopy;
40 clear += ss.clear;
41 append += ss.append;
42 moves += ss.moves;
43 toStream += ss.toStream;
44 setChar += ss.setChar;
45 getChar += ss.getChar;
48 copyOut += ss.copyOut;
49 rawAccess += ss.rawAccess;
51 chop += ss.chop;
52 trim += ss.trim;
53 find += ss.find;
56 cowShift += ss.cowShift;
59 live += ss.live;
60
61 return *this;
62}
63
64std::ostream &
65SBufStats::dump(std::ostream& os) const
66{
68 os <<
69 "SBuf stats:\nnumber of allocations: " << alloc <<
70 "\ncopy-allocations: " << allocCopy <<
71 "\ncopy-allocations from C String: " << allocFromCString <<
72 "\nlive references: " << live <<
73 "\nno-copy assignments: " << assignFast <<
74 "\nclearing operations: " << clear <<
75 "\nappend operations: " << append <<
76 "\nmove operations: " << moves <<
77 "\ndump-to-ostream: " << toStream <<
78 "\nset-char: " << setChar <<
79 "\nget-char: " << getChar <<
80 "\ncomparisons with data-scan: " << compareSlow <<
81 "\ncomparisons not requiring data-scan: " << compareFast <<
82 "\ncopy-out ops: " << copyOut <<
83 "\nraw access to memory: " << rawAccess <<
84 "\nNULL terminate C string: " << nulTerminate <<
85 "\nchop operations: " << chop <<
86 "\ntrim operations: " << trim <<
87 "\nfind: " << find <<
88 "\ncase-change ops: " << caseChange <<
89 "\nCOW completely avoided: " << cowAvoided <<
90 "\nCOW replaced with memmove(3): " << cowShift <<
91 "\nCOW requiring an empty buffer allocation: " << cowJustAlloc <<
92 "\nCOW requiring allocation and copying: " << cowAllocCopy <<
93 "\naverage store share factor: " <<
94 (ststats.live != 0 ? static_cast<float>(live)/ststats.live : 0) <<
95 std::endl;
96 return os;
97}
98
Various MemBlob class-wide statistics.
Definition: MemBlob.h:20
uint64_t live
number of MemBlob instances currently alive
Definition: MemBlob.h:31
static const MemBlobStats & GetStats()
obtain a const view of class-wide statistics
Definition: MemBlob.cc:149
uint64_t trim
number of trim operations
Definition: Stats.h:52
uint64_t append
number of append operations
Definition: Stats.h:41
std::ostream & dump(std::ostream &os) const
Dump statistics to an ostream.
Definition: Stats.cc:65
uint64_t cowShift
number of cow() calls requiring just a memmove(3) inside an old buffer
Definition: Stats.h:56
uint64_t nulTerminate
number of c_str() terminations
Definition: Stats.h:50
SBufStats & operator+=(const SBufStats &)
Definition: Stats.cc:34
uint64_t moves
number of move constructions/assignments
Definition: Stats.h:42
uint64_t cowJustAlloc
number of cow() calls requiring just a new empty buffer
Definition: Stats.h:57
uint64_t rawAccess
number of accesses to raw contents
Definition: Stats.h:49
uint64_t assignFast
number of no-copy assignment operations
Definition: Stats.h:39
static void RecordMemBlobSizeAtDestruct(size_t)
Record the size a MemBlob had when it was destructed.
Definition: Stats.cc:27
uint64_t cowAllocCopy
number of cow() calls requiring copying into a new buffer
Definition: Stats.h:58
uint64_t getChar
number of calls to at() and operator[]
Definition: Stats.h:45
uint64_t setChar
number of calls to setAt
Definition: Stats.h:44
uint64_t caseChange
number of toUpper and toLower operations
Definition: Stats.h:54
uint64_t cowAvoided
number of cow() calls requiring no expensive operations
Definition: Stats.h:55
static SizeRecorder SBufSizeAtDestructRecorder
collects statistics about SBuf sizes at SBuf destruction time
Definition: Stats.h:64
uint64_t compareFast
number of comparison operations not requiring data scan
Definition: Stats.h:47
uint64_t chop
number of chop operations
Definition: Stats.h:51
uint64_t clear
number of clear operations
Definition: Stats.h:40
static void RecordSBufSizeAtDestruct(size_t)
Record the size a SBuf had when it was destructed.
Definition: Stats.cc:20
static SizeRecorder MemBlobSizeAtDestructRecorder
collects statistics about MemBlob capacity at MemBlob destruction time
Definition: Stats.h:66
uint64_t toStream
number of write operations to ostreams
Definition: Stats.h:43
uint64_t compareSlow
number of comparison operations requiring data scan
Definition: Stats.h:46
uint64_t allocCopy
number of calls to SBuf copy-constructor
Definition: Stats.h:37
uint64_t alloc
number of calls to SBuf constructors
Definition: Stats.h:36
uint64_t find
number of find operations
Definition: Stats.h:53
uint64_t live
number of currently-allocated SBuf
Definition: Stats.h:59
uint64_t copyOut
number of data-copies to other forms of buffers
Definition: Stats.h:48
uint64_t allocFromCString
number of copy-allocations from c-strings
Definition: Stats.h:38
void(*)(size_t) SizeRecorder
function for collecting detailed size-related statistics
Definition: Stats.h:62

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors