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..a930af68693c5007a4ddb1ef9b7ae26e0cb3a3c9 |
--- /dev/null |
+++ b/chrome/browser/performance_monitor/process_metrics_history.h |
@@ -0,0 +1,69 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
Devlin
2013/09/12 00:44:47
nit: no (c)
|
+// 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 SetLastUpdateSequence(int new_update_sequence) { |
Devlin
2013/09/12 00:44:47
for functions that don't do (real) work, prefer un
oystein (OOO til 10th of July)
2013/09/12 15:02:31
Done.
|
+ last_update_sequence_ = new_update_sequence; |
+ } |
+ |
+ int GetLastUpdateSequence() const { return last_update_sequence_; } |
Devlin
2013/09/12 00:44:47
unix_hacker_style - "last_updated_sequence()"
oystein (OOO til 10th of July)
2013/09/12 15:02:31
Done.
|
+ |
+ // Average CPU over all the past sampling points since last reset. |
+ double GetAverageCPUUsage() { return accumulated_cpu_usage_ / sample_count_; } |
+ |
+ // // Average mem usage over all the past sampling points since last reset. |
Devlin
2013/09/12 00:44:47
double comment?
oystein (OOO til 10th of July)
2013/09/12 15:02:31
Done.
|
+ void GetAverageMemoryBytes(size_t* private_bytes, size_t* shared_bytes) { |
+ *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_ |