summaryrefslogtreecommitdiffstats
path: root/base/histogram.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-24 23:51:25 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-24 23:51:25 +0000
commite2951cf3bd7e591a64ad5199a61531dac0ec58d2 (patch)
tree3039f816f6fa46008865c1ce4b1dd15de7b48d5a /base/histogram.cc
parent0e8db94aef1b57355c3d154cb4682ce2f94c51eb (diff)
downloadchromium_src-e2951cf3bd7e591a64ad5199a61531dac0ec58d2.zip
chromium_src-e2951cf3bd7e591a64ad5199a61531dac0ec58d2.tar.gz
chromium_src-e2951cf3bd7e591a64ad5199a61531dac0ec58d2.tar.bz2
Use histograms to send interesting parts of the disk cache statistics.
Most of this CL deals with a derived implementation of histograms that just queries the size stats already generated by the disk cache. The exact number of buckets, and their distribution, is controlled directly by the new class and the disk cache stats code. Review URL: http://codereview.chromium.org/3069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/histogram.cc')
-rw-r--r--base/histogram.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/base/histogram.cc b/base/histogram.cc
index b4dede7..19dcf83 100644
--- a/base/histogram.cc
+++ b/base/histogram.cc
@@ -99,8 +99,8 @@ void Histogram::WriteAscii(bool graph_it, const std::string& newline,
// Calculate space needed to print bucket range numbers. Leave room to print
// nearly the largest bucket range without sliding over the histogram.
- size_t largest_non_empty_bucket = bucket_count_ - 1;
- while (0 == sample_.counts(largest_non_empty_bucket)) {
+ size_t largest_non_empty_bucket = bucket_count() - 1;
+ while (0 == snapshot.counts(largest_non_empty_bucket)) {
if (0 == largest_non_empty_bucket)
break; // All buckets are empty.
largest_non_empty_bucket--;
@@ -108,7 +108,7 @@ void Histogram::WriteAscii(bool graph_it, const std::string& newline,
// Calculate largest print width needed for any of our bucket range displays.
size_t print_width = 1;
- for (size_t i = 0; i < bucket_count_; ++i) {
+ for (size_t i = 0; i < bucket_count(); ++i) {
if (snapshot.counts(i)) {
size_t width = GetAsciiBucketRange(i).size() + 1;
if (width > print_width)
@@ -119,14 +119,14 @@ void Histogram::WriteAscii(bool graph_it, const std::string& newline,
int64 remaining = sample_count;
int64 past = 0;
// Output the actual histogram graph.
- for (size_t i = 0; i < bucket_count_; i++) {
+ for (size_t i = 0; i < bucket_count(); i++) {
Count current = snapshot.counts(i);
if (!current && !PrintEmptyBucket(i))
continue;
remaining -= current;
StringAppendF(output, "%#*s ", print_width, GetAsciiBucketRange(i).c_str());
- if (0 == current && i < bucket_count_ - 1 && 0 == snapshot.counts(i + 1)) {
- while (i < bucket_count_ - 1 && 0 == snapshot.counts(i + 1))
+ if (0 == current && i < bucket_count() - 1 && 0 == snapshot.counts(i + 1)) {
+ while (i < bucket_count() - 1 && 0 == snapshot.counts(i + 1))
i++;
output->append("... ");
output->append(newline);
@@ -159,7 +159,7 @@ void Histogram::Initialize() {
if (declared_max_ >= kSampleType_MAX)
declared_max_ = kSampleType_MAX - 1;
DCHECK(declared_min_ > 0); // We provide underflow bucket.
- DCHECK(declared_min_ < declared_max_);
+ DCHECK(declared_min_ <= declared_max_);
DCHECK(1 < bucket_count_);
size_t maximal_bucket_count = declared_max_ - declared_min_ + 2;
DCHECK(bucket_count_ <= maximal_bucket_count);
@@ -275,7 +275,7 @@ void Histogram::SetBucketRange(size_t i, Sample value) {
double Histogram::GetPeakBucketSize(const SampleSet& snapshot) const {
double max = 0;
- for (size_t i = 0; i < bucket_count_ ; i++) {
+ for (size_t i = 0; i < bucket_count() ; i++) {
double current_size = GetBucketSize(snapshot.counts(i), i);
if (current_size > max)
max = current_size;
@@ -322,9 +322,9 @@ void Histogram::WriteAsciiBucketContext(const int64 past,
const std::string Histogram::GetAsciiBucketRange(size_t i) const {
std::string result;
if (kHexRangePrintingFlag & flags_)
- StringAppendF(&result, "%#x", ranges_[i]);
+ StringAppendF(&result, "%#x", ranges(i));
else
- StringAppendF(&result, "%d", ranges_[i]);
+ StringAppendF(&result, "%d", ranges(i));
return result;
}