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

Unified Diff: base/metrics/histogram_unittest.cc

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed some unnecessary includes Created 4 years, 7 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.cc ('k') | base/metrics/persistent_histogram_allocator.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 58b72480018591f72679a6e1ff036727f25ada2c..668ac1ba7e83ad47bfd107beb97e407bff57d1a8 100644
--- a/base/metrics/histogram_unittest.cc
+++ b/base/metrics/histogram_unittest.cc
@@ -147,7 +147,7 @@ TEST_P(HistogramTest, NameMatchTest) {
EXPECT_EQ(2, samples->GetCount(10));
}
-// Check that delta calculations work correct.
+// Check that delta calculations work correctly.
TEST_P(HistogramTest, DeltaTest) {
HistogramBase* histogram =
Histogram::FactoryGet("DeltaHistogram", 1, 64, 8,
@@ -176,6 +176,32 @@ TEST_P(HistogramTest, DeltaTest) {
EXPECT_EQ(0, samples->TotalCount());
}
+// Check that final-delta calculations work correctly.
+TEST_P(HistogramTest, FinalDeltaTest) {
+ HistogramBase* histogram =
+ Histogram::FactoryGet("FinalDeltaHistogram", 1, 64, 8,
+ HistogramBase::kNoFlags);
+ histogram->Add(1);
+ histogram->Add(10);
+ histogram->Add(50);
+
+ std::unique_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());
+
+ histogram->Add(2);
+ histogram->Add(50);
+
+ samples = histogram->SnapshotFinalDelta();
+ EXPECT_EQ(2, samples->TotalCount());
+ EXPECT_EQ(1, samples->GetCount(2));
+ EXPECT_EQ(1, samples->GetCount(50));
+ EXPECT_EQ(samples->TotalCount(), samples->redundant_count());
+}
+
TEST_P(HistogramTest, ExponentialRangesTest) {
// Check that we got a nice exponential when there was enough room.
BucketRanges ranges(9);
« no previous file with comments | « base/metrics/histogram_snapshot_manager.cc ('k') | base/metrics/persistent_histogram_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698