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

Unified Diff: chrome/browser/performance_monitor/process_metrics_history.h

Issue 23825004: PerformanceMonitor: UMA alert for high browser CPU usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 7 years, 3 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: chrome/browser/performance_monitor/process_metrics_history.h
diff --git a/chrome/browser/performance_monitor/process_metrics_history.h b/chrome/browser/performance_monitor/process_metrics_history.h
new file mode 100644
index 0000000000000000000000000000000000000000..727f740c66964509296ca0c7738e26574ea48879
--- /dev/null
+++ b/chrome/browser/performance_monitor/process_metrics_history.h
@@ -0,0 +1,69 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_
+#define CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_
+
+#include "base/memory/linked_ptr.h"
+#include "base/process/process_handle.h"
+
+namespace base {
+class ProcessMetrics;
+}
+
+namespace performance_monitor {
+
+class ProcessMetricsHistory {
+ public:
+ ProcessMetricsHistory();
+ ~ProcessMetricsHistory();
+
+ // Configure this to monitor a specific process.
+ void Initialize(base::ProcessHandle process_handle,
+ int process_type,
+ int initial_update_sequence);
+
+ // End of a measurement cycle; check for performance issues and reset
+ // accumulated statistics.
+ void EndOfCycle();
+
+ // Gather metrics for the process and accumulate with past data.
+ void SampleMetrics();
+
+ // Used to mark when this object was last updated, so we can cull
+ // dead ones.
+ void set_last_update_sequence(int new_update_sequence) {
+ last_update_sequence_ = new_update_sequence;
+ }
+
+ int last_update_sequence() const { return last_update_sequence_; }
+
+ // Average CPU over all the past sampling points since last reset.
+ double GetAverageCPUUsage() { return accumulated_cpu_usage_ / sample_count_; }
Devlin 2013/09/12 18:20:42 const
oystein (OOO til 10th of July) 2013/09/12 19:03:24 Done.
+
+ // // Average mem usage.
Devlin 2013/09/12 18:20:42 1. you have two comment starts here - "// //" shou
oystein (OOO til 10th of July) 2013/09/12 19:03:24 Done.
+ void GetAverageMemoryBytes(size_t* private_bytes, size_t* shared_bytes) {
Devlin 2013/09/12 18:20:42 const
oystein (OOO til 10th of July) 2013/09/12 19:03:24 Done.
+ *private_bytes = accumulated_private_bytes_ / sample_count_;
+ *shared_bytes = accumulated_shared_bytes_ / sample_count_;
+ }
+
+ private:
+ void ResetCounters();
+ void RunPerformanceTriggers();
+
+ base::ProcessHandle process_handle_;
+ int process_type_;
+ linked_ptr<base::ProcessMetrics> process_metrics_;
+ int last_update_sequence_;
+
+ double accumulated_cpu_usage_;
+ double min_cpu_usage_;
+ size_t accumulated_private_bytes_;
+ size_t accumulated_shared_bytes_;
+ int sample_count_;
+};
+
+} // namespace performance_monitor
+
+#endif // CHROME_BROWSER_PERFORMANCE_MONITOR_PROCESS_METRICS_HISTORY_H_

Powered by Google App Engine
This is Rietveld 408576698