Stats.cc
Go to the documentation of this file.
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/MemBlob.h"
11 #include "sbuf/SBuf.h"
12 #include "sbuf/Stats.h"
13 
14 #include <iostream>
15 
16 SBufStats&
18 {
19  alloc += ss.alloc;
20  allocCopy += ss.allocCopy;
22  assignFast += ss.assignFast;
23  clear += ss.clear;
24  append += ss.append;
25  moves += ss.moves;
26  toStream += ss.toStream;
27  setChar += ss.setChar;
28  getChar += ss.getChar;
31  copyOut += ss.copyOut;
32  rawAccess += ss.rawAccess;
34  chop += ss.chop;
35  trim += ss.trim;
36  find += ss.find;
37  caseChange += ss.caseChange;
38  cowFast += ss.cowFast;
39  cowSlow += ss.cowSlow;
40  live += ss.live;
41 
42  return *this;
43 }
44 
45 std::ostream &
46 SBufStats::dump(std::ostream& os) const
47 {
48  MemBlobStats ststats = MemBlob::GetStats();
49  os <<
50  "SBuf stats:\nnumber of allocations: " << alloc <<
51  "\ncopy-allocations: " << allocCopy <<
52  "\ncopy-allocations from C String: " << allocFromCString <<
53  "\nlive references: " << live <<
54  "\nno-copy assignments: " << assignFast <<
55  "\nclearing operations: " << clear <<
56  "\nappend operations: " << append <<
57  "\nmove operations: " << moves <<
58  "\ndump-to-ostream: " << toStream <<
59  "\nset-char: " << setChar <<
60  "\nget-char: " << getChar <<
61  "\ncomparisons with data-scan: " << compareSlow <<
62  "\ncomparisons not requiring data-scan: " << compareFast <<
63  "\ncopy-out ops: " << copyOut <<
64  "\nraw access to memory: " << rawAccess <<
65  "\nNULL terminate C string: " << nulTerminate <<
66  "\nchop operations: " << chop <<
67  "\ntrim operations: " << trim <<
68  "\nfind: " << find <<
69  "\ncase-change ops: " << caseChange <<
70  "\nCOW not actually requiring a copy: " << cowFast <<
71  "\nCOW: " << cowSlow <<
72  "\naverage store share factor: " <<
73  (ststats.live != 0 ? static_cast<float>(live)/ststats.live : 0) <<
74  std::endl;
75  return os;
76 }
77 
uint64_t live
number of currently-allocated SBuf
Definition: Stats.h:51
std::ostream & dump(std::ostream &os) const
Dump statistics to an ostream.
Definition: Stats.cc:46
uint64_t chop
number of chop operations
Definition: Stats.h:45
uint64_t toStream
number of write operations to ostreams
Definition: Stats.h:37
uint64_t allocCopy
number of calls to SBuf copy-constructor
Definition: Stats.h:31
uint64_t assignFast
number of no-copy assignment operations
Definition: Stats.h:33
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:128
uint64_t append
number of append operations
Definition: Stats.h:35
uint64_t rawAccess
number of accesses to raw contents
Definition: Stats.h:43
uint64_t alloc
number of calls to SBuf constructors
Definition: Stats.h:30
uint64_t trim
number of trim operations
Definition: Stats.h:46
uint64_t clear
number of clear operations
Definition: Stats.h:34
uint64_t compareSlow
number of comparison operations requiring data scan
Definition: Stats.h:40
uint64_t copyOut
number of data-copies to other forms of buffers
Definition: Stats.h:42
uint64_t find
number of find operations
Definition: Stats.h:47
uint64_t cowFast
number of cow operations not actually requiring a copy
Definition: Stats.h:49
uint64_t caseChange
number of toUpper and toLower operations
Definition: Stats.h:48
uint64_t moves
number of move constructions/assignments
Definition: Stats.h:36
Various MemBlob class-wide statistics.
Definition: MemBlob.h:19
uint64_t compareFast
number of comparison operations not requiring data scan
Definition: Stats.h:41
uint64_t setChar
number of calls to setAt
Definition: Stats.h:38
SBufStats & operator+=(const SBufStats &)
Definition: Stats.cc:17
uint64_t allocFromCString
number of copy-allocations from c-strings
Definition: Stats.h:32
uint64_t nulTerminate
number of c_str() terminations
Definition: Stats.h:44
uint64_t getChar
number of calls to at() and operator[]
Definition: Stats.h:39
uint64_t cowSlow
number of cow operations requiring a copy
Definition: Stats.h:50

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors