]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add counter for SBuf::c_str() calls
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 6 Apr 2014 07:08:04 +0000 (00:08 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 6 Apr 2014 07:08:04 +0000 (00:08 -0700)
It is useful to know how many c_str() calls are being made as each
results in a possible reallocation.

src/SBuf.cc
src/SBuf.h

index 56f981bf3b00e7ae118e71b0d0d2df3f7493eee8..36d2491a40a45c598ee940619d096d911a6ff746 100644 (file)
@@ -59,7 +59,7 @@ SBufStats::SBufStats()
         : alloc(0), allocCopy(0), allocFromString(0), allocFromCString(0),
         assignFast(0), clear(0), append(0), toStream(0), setChar(0),
         getChar(0), compareSlow(0), compareFast(0), copyOut(0),
-        rawAccess(0), chop(0), trim(0), find(0), scanf(0),
+        rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0), scanf(0),
         caseChange(0), cowFast(0), cowSlow(0), live(0)
 {}
 
@@ -80,6 +80,7 @@ SBufStats::operator +=(const SBufStats& ss)
     compareFast += ss.compareFast;
     copyOut += ss.copyOut;
     rawAccess += ss.rawAccess;
+    nulTerminate += ss.nulTerminate;
     chop += ss.chop;
     trim += ss.trim;
     find += ss.find;
@@ -491,6 +492,7 @@ SBuf::c_str()
     *rawSpace(1) = '\0';
     ++store_->size;
     ++stats.setChar;
+    ++stats.nulTerminate;
     return buf();
 }
 
@@ -764,6 +766,7 @@ SBufStats::dump(std::ostream& os) const
     "\ncomparisons not requiring data-scan: " << compareFast <<
     "\ncopy-out ops: " << copyOut <<
     "\nraw access to memory: " << rawAccess <<
+    "\nNULL terminate C string: " << nulTerminate <<
     "\nchop operations: " << chop <<
     "\ntrim operations: " << trim <<
     "\nfind: " << find <<
index 31deb00882548c937c84080fa298039f0e6c0893..93bc64a608dc6e3851677a5117f1a30c6d923b38 100644 (file)
@@ -77,6 +77,7 @@ public:
     uint64_t compareFast; ///<number of comparison operations not requiring data scan
     uint64_t copyOut; ///<number of data-copies to other forms of buffers
     uint64_t rawAccess; ///<number of accesses to raw contents
+    uint64_t nulTerminate; ///<number of c_str() terminations
     uint64_t chop;  ///<number of chop operations
     uint64_t trim;  ///<number of trim operations
     uint64_t find;  ///<number of find operations