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

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

Issue 546193002: Add an 'Idle Wake Ups' metric to the Linux task manager, implement backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wakeclean
Patch Set: rebase Created 6 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 unified diff | Download patch
« no previous file with comments | « base/process/process_metrics.h ('k') | base/process/process_metrics_linux.cc » ('j') | no next file with comments »
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 double ProcessMetrics::GetPlatformIndependentCPUUsage() { 46 double ProcessMetrics::GetPlatformIndependentCPUUsage() {
47 #if defined(OS_WIN) 47 #if defined(OS_WIN)
48 return GetCPUUsage() * processor_count_; 48 return GetCPUUsage() * processor_count_;
49 #else 49 #else
50 return GetCPUUsage(); 50 return GetCPUUsage();
51 #endif 51 #endif
52 } 52 }
53 53
54 #if !defined(OS_MACOSX) 54 #if defined(OS_MACOSX) || defined(OS_LINUX)
55 int ProcessMetrics::CalculateIdleWakeupsPerSecond(
56 uint64 absolute_idle_wakeups) {
57 TimeTicks time = TimeTicks::Now();
58
59 if (last_absolute_idle_wakeups_ == 0) {
60 // First call, just set the last values.
61 last_idle_wakeups_time_ = time;
62 last_absolute_idle_wakeups_ = absolute_idle_wakeups;
63 return 0;
64 }
65
66 int64 wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_;
67 int64 time_delta = (time - last_idle_wakeups_time_).InMicroseconds();
68 if (time_delta == 0) {
69 NOTREACHED();
70 return 0;
71 }
72
73 last_idle_wakeups_time_ = time;
74 last_absolute_idle_wakeups_ = absolute_idle_wakeups;
75
76 // Round to average wakeups per second.
77 int64 wakeups_delta_for_ms = wakeups_delta * Time::kMicrosecondsPerSecond;
78 return (wakeups_delta_for_ms + time_delta / 2) / time_delta;
79 }
80 #else
55 int ProcessMetrics::GetIdleWakeupsPerSecond() { 81 int ProcessMetrics::GetIdleWakeupsPerSecond() {
56 NOTIMPLEMENTED(); // http://crbug.com/120488 82 NOTIMPLEMENTED(); // http://crbug.com/120488
57 return 0; 83 return 0;
58 } 84 }
59 #endif // !defined(OS_MACOSX) 85 #endif // defined(OS_MACOSX) || defined(OS_LINUX)
60 86
61 } // namespace base 87 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics.h ('k') | base/process/process_metrics_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698