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

Unified Diff: base/process_util_mac.mm

Issue 548135: Mac: Fix %cpu in task manager. (Closed)
Patch Set: Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_mac.mm
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm
index 509828b6b25b790fd2a8b69943fd937f8efaa8e2..9c0a2a4973f1c7aac93c36f9836a3e5c6f798919 100644
--- a/base/process_util_mac.mm
+++ b/base/process_util_mac.mm
@@ -255,8 +255,8 @@ double ProcessMetrics::GetCPUUsage() {
kern_return_t kr;
- // TODO(thakis): Libtop doesn't use thread info. How can they get away
- // without it?
+ // Libtop explicitly loops over the threads (libtop_pinfo_update_cpu_usage()
+ // in libtop.c), but this is more concise and gives the same results:
task_thread_times_info thread_info_data;
mach_msg_type_number_t thread_info_count = TASK_THREAD_TIMES_INFO_COUNT;
kr = task_info(task,
@@ -307,8 +307,7 @@ double ProcessMetrics::GetCPUUsage() {
return 0;
// We add time_delta / 2 so the result is rounded.
- double cpu = static_cast<double>(
- (system_time_delta * 100.0 + time_delta / 2.0) / time_delta);
+ double cpu = static_cast<double>((system_time_delta * 100.0) / time_delta);
last_system_time_ = task_time;
last_time_ = time;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698