]>
Commit | Line | Data |
---|---|---|
b268925c | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 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 | #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::SBufStats() | |
17 | : alloc(0), allocCopy(0), allocFromCString(0), | |
18 | assignFast(0), clear(0), append(0), moves(0), toStream(0), setChar(0), | |
19 | getChar(0), compareSlow(0), compareFast(0), copyOut(0), | |
5bf2c0cb | 20 | rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0), |
b268925c AJ |
21 | caseChange(0), cowFast(0), cowSlow(0), live(0) |
22 | {} | |
23 | ||
24 | SBufStats& | |
25 | SBufStats::operator +=(const SBufStats& ss) | |
26 | { | |
27 | alloc += ss.alloc; | |
28 | allocCopy += ss.allocCopy; | |
29 | allocFromCString += ss.allocFromCString; | |
30 | assignFast += ss.assignFast; | |
31 | clear += ss.clear; | |
32 | append += ss.append; | |
33 | moves += ss.moves; | |
34 | toStream += ss.toStream; | |
35 | setChar += ss.setChar; | |
36 | getChar += ss.getChar; | |
37 | compareSlow += ss.compareSlow; | |
38 | compareFast += ss.compareFast; | |
39 | copyOut += ss.copyOut; | |
40 | rawAccess += ss.rawAccess; | |
41 | nulTerminate += ss.nulTerminate; | |
42 | chop += ss.chop; | |
43 | trim += ss.trim; | |
44 | find += ss.find; | |
b268925c AJ |
45 | caseChange += ss.caseChange; |
46 | cowFast += ss.cowFast; | |
47 | cowSlow += ss.cowSlow; | |
48 | live += ss.live; | |
49 | ||
50 | return *this; | |
51 | } | |
52 | ||
53 | std::ostream & | |
54 | SBufStats::dump(std::ostream& os) const | |
55 | { | |
56 | MemBlobStats ststats = MemBlob::GetStats(); | |
57 | os << | |
58 | "SBuf stats:\nnumber of allocations: " << alloc << | |
59 | "\ncopy-allocations: " << allocCopy << | |
60 | "\ncopy-allocations from C String: " << allocFromCString << | |
61 | "\nlive references: " << live << | |
62 | "\nno-copy assignments: " << assignFast << | |
63 | "\nclearing operations: " << clear << | |
64 | "\nappend operations: " << append << | |
65 | "\nmove operations: " << moves << | |
66 | "\ndump-to-ostream: " << toStream << | |
67 | "\nset-char: " << setChar << | |
68 | "\nget-char: " << getChar << | |
69 | "\ncomparisons with data-scan: " << compareSlow << | |
70 | "\ncomparisons not requiring data-scan: " << compareFast << | |
71 | "\ncopy-out ops: " << copyOut << | |
72 | "\nraw access to memory: " << rawAccess << | |
73 | "\nNULL terminate C string: " << nulTerminate << | |
74 | "\nchop operations: " << chop << | |
75 | "\ntrim operations: " << trim << | |
76 | "\nfind: " << find << | |
b268925c AJ |
77 | "\ncase-change ops: " << caseChange << |
78 | "\nCOW not actually requiring a copy: " << cowFast << | |
79 | "\nCOW: " << cowSlow << | |
80 | "\naverage store share factor: " << | |
81 | (ststats.live != 0 ? static_cast<float>(live)/ststats.live : 0) << | |
82 | std::endl; | |
83 | return os; | |
84 | } | |
85 |