Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: base/metrics/histogram_unittest.cc

Issue 1485763002: Merge multiple histogram snapshots into single one for reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: addressed remaining review comments by Alexei Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/histogram_snapshot_manager_unittest.cc ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram_unittest.cc
diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc
index 2931897589e7834fba7fbdb60476aae901be365b..beb6a71ede63c81168a851d099c9afbe8f2918bb 100644
--- a/base/metrics/histogram_unittest.cc
+++ b/base/metrics/histogram_unittest.cc
@@ -32,7 +32,7 @@ namespace base {
// heap.
class HistogramTest : public testing::TestWithParam<bool> {
protected:
- const int32_t kAllocatorMemorySize = 4 << 20; // 4 MiB
+ const int32_t kAllocatorMemorySize = 8 << 20; // 8 MiB
HistogramTest() : use_persistent_histogram_allocator_(GetParam()) {}
@@ -235,6 +235,35 @@ TEST_P(HistogramTest, NameMatchTest) {
EXPECT_EQ(2, samples->GetCount(10));
}
+// Check that delta calculations work correct.
+TEST_P(HistogramTest, DeltaTest) {
+ HistogramBase* histogram =
+ Histogram::FactoryGet("DeltaHistogram", 1, 64, 8,
+ HistogramBase::kNoFlags);
+ histogram->Add(1);
+ histogram->Add(10);
+ histogram->Add(50);
+
+ scoped_ptr<HistogramSamples> samples = histogram->SnapshotDelta();
+ EXPECT_EQ(3, samples->TotalCount());
+ EXPECT_EQ(1, samples->GetCount(1));
+ EXPECT_EQ(1, samples->GetCount(10));
+ EXPECT_EQ(1, samples->GetCount(50));
+ EXPECT_EQ(samples->TotalCount(), samples->redundant_count());
+
+ samples = histogram->SnapshotDelta();
+ EXPECT_EQ(0, samples->TotalCount());
+
+ histogram->Add(10);
+ histogram->Add(10);
+ samples = histogram->SnapshotDelta();
+ EXPECT_EQ(2, samples->TotalCount());
+ EXPECT_EQ(2, samples->GetCount(10));
+
+ samples = histogram->SnapshotDelta();
+ EXPECT_EQ(0, samples->TotalCount());
+}
+
TEST_P(HistogramTest, ExponentialRangesTest) {
// Check that we got a nice exponential when there was enough room.
BucketRanges ranges(9);
@@ -547,7 +576,7 @@ TEST_P(HistogramTest, CorruptBucketBounds) {
bucket_ranges->set_range(2, bucket_ranges->range(1));
bucket_ranges->set_range(1, tmp);
- EXPECT_EQ(0, histogram->FindCorruption(*snapshot));
+ EXPECT_EQ(0U, histogram->FindCorruption(*snapshot));
// Show that two simple changes don't offset each other
bucket_ranges->set_range(3, bucket_ranges->range(3) + 1);
« no previous file with comments | « base/metrics/histogram_snapshot_manager_unittest.cc ('k') | base/metrics/sparse_histogram.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698