OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process/process_metrics.h" | 9 #include "base/process/process_metrics.h" |
10 | 10 |
11 #include "chrome/browser/performance_monitor/constants.h" | |
12 #include "chrome/browser/performance_monitor/process_metrics_history.h" | 11 #include "chrome/browser/performance_monitor/process_metrics_history.h" |
13 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
14 #include "content/public/browser/browser_child_process_host.h" | 13 #include "content/public/browser/browser_child_process_host.h" |
15 #endif | 14 #endif |
16 #include "content/public/common/process_type.h" | 15 #include "content/public/common/process_type.h" |
17 | 16 |
18 namespace performance_monitor { | 17 namespace performance_monitor { |
19 | 18 |
| 19 // If a process is consistently above this CPU utilization percentage over time, |
| 20 // we consider it as high and may take action. |
| 21 const float kHighCPUUtilizationThreshold = 90.0f; |
| 22 |
20 ProcessMetricsHistory::ProcessMetricsHistory() | 23 ProcessMetricsHistory::ProcessMetricsHistory() |
21 : process_handle_(0), | 24 : process_handle_(0), |
22 process_type_(content::PROCESS_TYPE_UNKNOWN), | 25 process_type_(content::PROCESS_TYPE_UNKNOWN), |
23 last_update_sequence_(0) { | 26 last_update_sequence_(0) { |
24 ResetCounters(); | 27 ResetCounters(); |
25 } | 28 } |
26 | 29 |
27 ProcessMetricsHistory::~ProcessMetricsHistory() {} | 30 ProcessMetricsHistory::~ProcessMetricsHistory() {} |
28 | 31 |
29 void ProcessMetricsHistory::ResetCounters() { | 32 void ProcessMetricsHistory::ResetCounters() { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 kHistogramMin, kHistogramMax, kHistogramBucketCount); | 130 kHistogramMin, kHistogramMax, kHistogramBucketCount); |
128 if (min_cpu_usage_ > kHighCPUUtilizationThreshold) | 131 if (min_cpu_usage_ > kHighCPUUtilizationThreshold) |
129 UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.PPAPIProcess", true); | 132 UMA_HISTOGRAM_BOOLEAN("PerformanceMonitor.HighCPU.PPAPIProcess", true); |
130 break; | 133 break; |
131 default: | 134 default: |
132 break; | 135 break; |
133 } | 136 } |
134 } | 137 } |
135 | 138 |
136 } // namespace performance_monitor | 139 } // namespace performance_monitor |
OLD | NEW |