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

Side by Side Diff: chrome/browser/metrics/process_memory_metrics_emitter_browsertest.cc

Issue 2904703002: Add a histogram for total private memory footprint. (Closed)
Patch Set: Update tests to check private memory footprint on Windows. Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/metrics/process_memory_metrics_emitter.h" 5 #include "chrome/browser/metrics/process_memory_metrics_emitter.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/test/trace_event_analyzer.h" 10 #include "base/test/trace_event_analyzer.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (check_minimum) 79 if (check_minimum)
80 EXPECT_GT(samples->sum(), 0u) << name; 80 EXPECT_GT(samples->sum(), 0u) << name;
81 81
82 // As a sanity check, no memory stat should exceed 1 GB. 82 // As a sanity check, no memory stat should exceed 1 GB.
83 int64_t maximum_expected_size = 1ll << 30; 83 int64_t maximum_expected_size = 1ll << 30;
84 EXPECT_LT(samples->sum(), maximum_expected_size) << name; 84 EXPECT_LT(samples->sum(), maximum_expected_size) << name;
85 } 85 }
86 86
87 void CheckAllMemoryMetrics(const base::HistogramTester& histogram_tester, 87 void CheckAllMemoryMetrics(const base::HistogramTester& histogram_tester,
88 int count) { 88 int count) {
89 #if (defined(OS_MACOSX) && !defined(OS_IOS)) || defined(OS_LINUX) || \
90 defined(OS_ANDROID)
91 bool private_footprint_implemented = true;
92 #else
93 bool private_footprint_implemented = false;
94 #endif
95
96 CheckMemoryMetric("Memory.Experimental.Browser2.Malloc", histogram_tester, 89 CheckMemoryMetric("Memory.Experimental.Browser2.Malloc", histogram_tester,
97 count, true); 90 count, true);
98 CheckMemoryMetric("Memory.Experimental.Browser2.Resident", histogram_tester, 91 CheckMemoryMetric("Memory.Experimental.Browser2.Resident", histogram_tester,
99 count, true); 92 count, true);
100 CheckMemoryMetric("Memory.Experimental.Browser2.PrivateMemoryFootprint", 93 CheckMemoryMetric("Memory.Experimental.Browser2.PrivateMemoryFootprint",
101 histogram_tester, count, private_footprint_implemented); 94 histogram_tester, count, true);
102 CheckMemoryMetric("Memory.Experimental.Renderer2.Malloc", histogram_tester, 95 CheckMemoryMetric("Memory.Experimental.Renderer2.Malloc", histogram_tester,
103 count, true); 96 count, true);
104 CheckMemoryMetric("Memory.Experimental.Renderer2.Resident", histogram_tester, 97 CheckMemoryMetric("Memory.Experimental.Renderer2.Resident", histogram_tester,
105 count, true); 98 count, true);
106 CheckMemoryMetric("Memory.Experimental.Renderer2.BlinkGC", histogram_tester, 99 CheckMemoryMetric("Memory.Experimental.Renderer2.BlinkGC", histogram_tester,
107 count, false); 100 count, false);
108 CheckMemoryMetric("Memory.Experimental.Renderer2.PartitionAlloc", 101 CheckMemoryMetric("Memory.Experimental.Renderer2.PartitionAlloc",
109 histogram_tester, count, false); 102 histogram_tester, count, false);
110 CheckMemoryMetric("Memory.Experimental.Renderer2.V8", histogram_tester, count, 103 CheckMemoryMetric("Memory.Experimental.Renderer2.V8", histogram_tester, count,
111 true); 104 true);
112 CheckMemoryMetric("Memory.Experimental.Renderer2.PrivateMemoryFootprint", 105 CheckMemoryMetric("Memory.Experimental.Renderer2.PrivateMemoryFootprint",
113 histogram_tester, count, private_footprint_implemented); 106 histogram_tester, count, true);
107 CheckMemoryMetric("Memory.Experimental.Total2.PrivateMemoryFootprint",
108 histogram_tester, count, true);
114 } 109 }
115 110
116 } // namespace 111 } // namespace
117 112
118 class ProcessMemoryMetricsEmitterTest : public InProcessBrowserTest { 113 class ProcessMemoryMetricsEmitterTest : public InProcessBrowserTest {
119 public: 114 public:
120 ProcessMemoryMetricsEmitterTest() {} 115 ProcessMemoryMetricsEmitterTest() {}
121 ~ProcessMemoryMetricsEmitterTest() override {} 116 ~ProcessMemoryMetricsEmitterTest() override {}
122 117
123 private: 118 private:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Only the last emitter should stop the run loop. 220 // Only the last emitter should stop the run loop.
226 auto emitter = base::MakeRefCounted<ProcessMemoryMetricsEmitterFake>( 221 auto emitter = base::MakeRefCounted<ProcessMemoryMetricsEmitterFake>(
227 (i == count - 1) ? &run_loop : nullptr); 222 (i == count - 1) ? &run_loop : nullptr);
228 emitter->FetchAndEmitProcessMemoryMetrics(); 223 emitter->FetchAndEmitProcessMemoryMetrics();
229 } 224 }
230 225
231 run_loop.Run(); 226 run_loop.Run();
232 227
233 CheckAllMemoryMetrics(histogram_tester, count); 228 CheckAllMemoryMetrics(histogram_tester, count);
234 } 229 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/process_memory_metrics_emitter.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698