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

Unified Diff: base/chromeos/memory_pressure_observer_chromeos.cc

Issue 874483008: Add UMA stats to get the quality of service of memory pressure handling scheme in ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Just add a variable kNumMemoryPressureLevels Created 5 years, 11 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
Index: base/chromeos/memory_pressure_observer_chromeos.cc
diff --git a/base/chromeos/memory_pressure_observer_chromeos.cc b/base/chromeos/memory_pressure_observer_chromeos.cc
index 8112c761e5e713e747cb015d8226e62a754c87a8..bbb8cec38bea210aa3b3b13258d8a1769eddc9b0 100644
--- a/base/chromeos/memory_pressure_observer_chromeos.cc
+++ b/base/chromeos/memory_pressure_observer_chromeos.cc
@@ -5,6 +5,7 @@
#include "base/chromeos/memory_pressure_observer_chromeos.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/histogram_macros.h"
#include "base/process/process_metrics.h"
#include "base/time/time.h"
@@ -29,6 +30,10 @@ const int kNormalMemoryPressureCriticalThresholdPercent = 90;
const int kAggressiveMemoryPressureModerateThresholdPercent = 35;
const int kAggressiveMemoryPressureCriticalThresholdPercent = 70;
+// Number of memory pressure levels. Should update this value if more memory
+// pressure level is introduced in MemoryPressureListener::MemoryPressureLevel.
Mr4D (OOO till 08-26) 2015/02/04 00:11:19 ... if more memory pressure levels are introduced
+const int kNumMemoryPressureLevels = 3;
+
// Converts a |MemoryPressureThreshold| value into a used memory percentage for
// the moderate pressure event.
int GetModerateMemoryThresholdInPercent(
@@ -51,6 +56,13 @@ int GetCriticalMemoryThresholdInPercent(
: kNormalMemoryPressureCriticalThresholdPercent;
}
+// Record UMA histogram statistics for the current memory pressure level.
+void RecordMemoryStatistics(
+ MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
+ UMA_HISTOGRAM_ENUMERATION("ChromeOS.MemoryPressureLevel",
+ memory_pressure_level, kNumMemoryPressureLevels);
+}
+
// Converts free percent of memory into a memory pressure value.
MemoryPressureListener::MemoryPressureLevel GetMemoryPressureLevelFromFillLevel(
int actual_fill_level,
@@ -92,7 +104,8 @@ void MemoryPressureObserverChromeOS::ScheduleEarlyCheck() {
void MemoryPressureObserverChromeOS::StartObserving() {
timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kMemoryPressureIntervalMs),
- Bind(&MemoryPressureObserverChromeOS::CheckMemoryPressure,
+ Bind(&MemoryPressureObserverChromeOS::
+ CheckMemoryPressureAndRecordStatistics,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -101,6 +114,11 @@ void MemoryPressureObserverChromeOS::StopObserving() {
timer_.Stop();
}
+void MemoryPressureObserverChromeOS::CheckMemoryPressureAndRecordStatistics() {
+ CheckMemoryPressure();
+ RecordMemoryStatistics(current_memory_pressure_level_);
Mr4D (OOO till 08-26) 2015/02/04 00:11:19 In this case you can pull the content of the funct
+}
+
void MemoryPressureObserverChromeOS::CheckMemoryPressure() {
MemoryPressureListener::MemoryPressureLevel old_pressure =
current_memory_pressure_level_;

Powered by Google App Engine
This is Rietveld 408576698