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

Side by Side Diff: base/process/process_metrics.cc

Issue 2667023004: Add comments explaining Task Manager idle wakeups computation. (Closed)
Patch Set: Restore code, add a comment. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/process/process_metrics_mac.cc » ('j') | base/process/process_metrics_mac.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/process/process_metrics.h" 5 #include "base/process/process_metrics.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int64_t wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_; 77 int64_t wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_;
78 int64_t time_delta = (time - last_idle_wakeups_time_).InMicroseconds(); 78 int64_t time_delta = (time - last_idle_wakeups_time_).InMicroseconds();
79 if (time_delta == 0) { 79 if (time_delta == 0) {
80 NOTREACHED(); 80 NOTREACHED();
81 return 0; 81 return 0;
82 } 82 }
83 83
84 last_idle_wakeups_time_ = time; 84 last_idle_wakeups_time_ = time;
85 last_absolute_idle_wakeups_ = absolute_idle_wakeups; 85 last_absolute_idle_wakeups_ = absolute_idle_wakeups;
86 86
87 // Round to average wakeups per second.
88 int64_t wakeups_delta_for_ms = wakeups_delta * Time::kMicrosecondsPerSecond; 87 int64_t wakeups_delta_for_ms = wakeups_delta * Time::kMicrosecondsPerSecond;
88 // Round the result up by adding 1/2 (the second term resolves to 1/2 without
89 // dropping down into floating point).
brucedawson 2017/02/02 19:52:03 It's funny how the set of idioms that are obvious
89 return (wakeups_delta_for_ms + time_delta / 2) / time_delta; 90 return (wakeups_delta_for_ms + time_delta / 2) / time_delta;
90 } 91 }
91 #else 92 #else
92 int ProcessMetrics::GetIdleWakeupsPerSecond() { 93 int ProcessMetrics::GetIdleWakeupsPerSecond() {
93 NOTIMPLEMENTED(); // http://crbug.com/120488 94 NOTIMPLEMENTED(); // http://crbug.com/120488
94 return 0; 95 return 0;
95 } 96 }
96 #endif // defined(OS_MACOSX) || defined(OS_LINUX) 97 #endif // defined(OS_MACOSX) || defined(OS_LINUX)
97 98
98 } // namespace base 99 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics_mac.cc » ('j') | base/process/process_metrics_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698