Bug 811419 - fix accumulation of the zero bucket in flag histograms; r=taras
authorNathan Froyd <froydnj@mozilla.com>
Tue, 13 Nov 2012 14:55:02 -0500
changeset 113182 615579ab42ff4f6520aee3a9163dc977e003a132
parent 113181 0a7efaf3ac7a4865bdca036d50664d281d11ae7c
child 113183 3b2f5b980477052f5cf87b1ffb00cf18ed231629
push id23859
push useremorley@mozilla.com
push dateWed, 14 Nov 2012 14:36:31 +0000
treeherdermozilla-central@87928cd21b40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstaras
bugs811419
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 811419 - fix accumulation of the zero bucket in flag histograms; r=taras
ipc/chromium/src/base/histogram.cc
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
--- a/ipc/chromium/src/base/histogram.cc
+++ b/ipc/chromium/src/base/histogram.cc
@@ -950,17 +950,17 @@ FlagHistogram::FactoryGet(const std::str
   Histogram *h(nullptr);
 
   if (!StatisticsRecorder::FindHistogram(name, &h)) {
     // To avoid racy destruction at shutdown, the following will be leaked.
     FlagHistogram *fh = new FlagHistogram(name);
     fh->InitializeBucketRange();
     fh->SetFlags(flags);
     size_t zero_index = fh->BucketIndex(0);
-    fh->Histogram::Accumulate(1, 1, zero_index);
+    fh->Histogram::Accumulate(0, 1, zero_index);
     h = StatisticsRecorder::RegisterOrDeleteDuplicate(fh);
   }
 
   return h;
 }
 
 FlagHistogram::FlagHistogram(const std::string &name)
   : BooleanHistogram(name), mSwitched(false) {
@@ -978,17 +978,17 @@ FlagHistogram::Accumulate(Sample value, 
   if (mSwitched) {
     return;
   }
 
   mSwitched = true;
   DCHECK_EQ(value, 1);
   Histogram::Accumulate(value, 1, index);
   size_t zero_index = BucketIndex(0);
-  Histogram::Accumulate(1, -1, zero_index);
+  Histogram::Accumulate(0, -1, zero_index);
 }
 
 void
 FlagHistogram::AddSampleSet(const SampleSet& sample) {
   DCHECK_EQ(bucket_count(), sample.size());
   // We can't be sure the SampleSet provided came from another FlagHistogram,
   // so we take the following steps:
   //  - If our flag has already been set do nothing.
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -204,17 +204,17 @@ function checkPayload(request, reason, s
   do_check_false(IGNORE_CLONED_HISTOGRAM in payload.histograms);
 
   // Flag histograms should automagically spring to life.
   const expected_flag = {
     range: [1, 2],
     bucket_count: 3,
     histogram_type: 3,
     values: {0:1, 1:0},
-    sum: 1
+    sum: 0
   };
   let flag = payload.histograms[TELEMETRY_TEST_FLAG];
   do_check_eq(uneval(flag), uneval(expected_flag));
 
   // There should be one successful report from the previous telemetry ping.
   const expected_tc = {
     range: [1, 2],
     bucket_count: 3,