OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/jankometer.h" | 7 #include "chrome/browser/jankometer.h" |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Time at which the current message processing began. | 112 // Time at which the current message processing began. |
113 TimeTicks begin_process_message_; | 113 TimeTicks begin_process_message_; |
114 | 114 |
115 // Time the current message spent in the queue -- delta between message | 115 // Time the current message spent in the queue -- delta between message |
116 // construction time and message processing time. | 116 // construction time and message processing time. |
117 TimeDelta queueing_time_; | 117 TimeDelta queueing_time_; |
118 | 118 |
119 // Counters for the two types of jank we measure. | 119 // Counters for the two types of jank we measure. |
120 base::StatsCounter slow_processing_counter_; // Msgs w/ long proc time. | 120 base::StatsCounter slow_processing_counter_; // Msgs w/ long proc time. |
121 base::StatsCounter queueing_delay_counter_; // Msgs w/ long queueing delay. | 121 base::StatsCounter queueing_delay_counter_; // Msgs w/ long queueing delay. |
122 scoped_refptr<base::Histogram> process_times_; // Time spent proc. task. | 122 base::Histogram* const process_times_; // Time spent proc. task. |
123 scoped_refptr<base::Histogram> total_times_; // Total queueing plus proc. | 123 base::Histogram* const total_times_; // Total queueing plus proc. |
124 JankWatchdog total_time_watchdog_; // Watching for excessive total_time. | 124 JankWatchdog total_time_watchdog_; // Watching for excessive total_time. |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(JankObserverHelper); | 126 DISALLOW_COPY_AND_ASSIGN(JankObserverHelper); |
127 }; | 127 }; |
128 | 128 |
129 JankObserverHelper::JankObserverHelper( | 129 JankObserverHelper::JankObserverHelper( |
130 const std::string& thread_name, | 130 const std::string& thread_name, |
131 const TimeDelta& excessive_duration, | 131 const TimeDelta& excessive_duration, |
132 bool watchdog_enable) | 132 bool watchdog_enable) |
133 : max_message_delay_(excessive_duration), | 133 : max_message_delay_(excessive_duration), |
134 measure_current_message_(true), | 134 measure_current_message_(true), |
135 events_till_measurement_(0), | 135 events_till_measurement_(0), |
136 slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), | 136 slow_processing_counter_(std::string("Chrome.SlowMsg") + thread_name), |
137 queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), | 137 queueing_delay_counter_(std::string("Chrome.DelayMsg") + thread_name), |
| 138 process_times_(base::Histogram::FactoryGet( |
| 139 std::string("Chrome.ProcMsgL ") + thread_name, |
| 140 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag)), |
| 141 total_times_(base::Histogram::FactoryGet( |
| 142 std::string("Chrome.TotalMsgL ") + thread_name, |
| 143 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag)), |
138 total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { | 144 total_time_watchdog_(excessive_duration, thread_name, watchdog_enable) { |
139 process_times_ = base::Histogram::FactoryGet( | |
140 std::string("Chrome.ProcMsgL ") + thread_name, | |
141 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag); | |
142 total_times_ = base::Histogram::FactoryGet( | |
143 std::string("Chrome.TotalMsgL ") + thread_name, | |
144 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag); | |
145 if (discard_count_ > 0) { | 145 if (discard_count_ > 0) { |
146 // Select a vaguely random sample-start-point. | 146 // Select a vaguely random sample-start-point. |
147 events_till_measurement_ = static_cast<int>( | 147 events_till_measurement_ = static_cast<int>( |
148 (TimeTicks::Now() - TimeTicks()).InSeconds() % (discard_count_ + 1)); | 148 (TimeTicks::Now() - TimeTicks()).InSeconds() % (discard_count_ + 1)); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 JankObserverHelper::~JankObserverHelper() {} | 152 JankObserverHelper::~JankObserverHelper() {} |
153 | 153 |
154 // Called when a message has just begun processing, initializes | 154 // Called when a message has just begun processing, initializes |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 delete ui_observer; | 408 delete ui_observer; |
409 ui_observer = NULL; | 409 ui_observer = NULL; |
410 } | 410 } |
411 if (io_observer) { | 411 if (io_observer) { |
412 // IO thread can't be running when we remove observers. | 412 // IO thread can't be running when we remove observers. |
413 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); | 413 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); |
414 delete io_observer; | 414 delete io_observer; |
415 io_observer = NULL; | 415 io_observer = NULL; |
416 } | 416 } |
417 } | 417 } |
OLD | NEW |