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

Side by Side Diff: base/process/process_metrics_mac.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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <mach/mach.h> 7 #include <mach/mach.h>
8 #include <mach/mach_vm.h> 8 #include <mach/mach_vm.h>
9 #include <mach/shared_region.h> 9 #include <mach/shared_region.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 mach_msg_type_number_t power_info_count = TASK_POWER_INFO_COUNT; 317 mach_msg_type_number_t power_info_count = TASK_POWER_INFO_COUNT;
318 kern_return_t kr = task_info(task, 318 kern_return_t kr = task_info(task,
319 TASK_POWER_INFO, 319 TASK_POWER_INFO,
320 reinterpret_cast<task_info_t>(&power_info_data), 320 reinterpret_cast<task_info_t>(&power_info_data),
321 &power_info_count); 321 &power_info_count);
322 if (kr != KERN_SUCCESS) { 322 if (kr != KERN_SUCCESS) {
323 // Most likely cause: |task| is a zombie, or this is on a pre-10.8.4 system 323 // Most likely cause: |task| is a zombie, or this is on a pre-10.8.4 system
324 // where TASK_POWER_INFO isn't supported yet. 324 // where TASK_POWER_INFO isn't supported yet.
325 return 0; 325 return 0;
326 } 326 }
327
328 // The task_power_info struct contains two wakeup counters:
329 // task_interrupt_wakeups and task_platform_idle_wakeups.
330 // task_interrupt_wakeups is the total number of wakeups generated by the
331 // process, and is the number that Activity Monitor reports.
332 // task_platform_idle_wakeups is a subset of task_interrupt_wakeups that
333 // tallies the number of times the processor was taken out of its low-power
334 // idle state to handle a wakeup. task_platform_idle_wakeups therefore result
335 // in a greater power increase than the other interrupts which occur while the
336 // CPU is already working, and reducing them has a greater overall impact on
337 // power usage. See the powermetrics man page for more info.
brucedawson 2017/02/02 19:52:03 That's pretty cool. I wish we had that information
327 return CalculateIdleWakeupsPerSecond( 338 return CalculateIdleWakeupsPerSecond(
328 power_info_data.task_platform_idle_wakeups); 339 power_info_data.task_platform_idle_wakeups);
329 } 340 }
330 341
331 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { 342 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const {
332 return false; 343 return false;
333 } 344 }
334 345
335 ProcessMetrics::ProcessMetrics(ProcessHandle process, 346 ProcessMetrics::ProcessMetrics(ProcessHandle process,
336 PortProvider* port_provider) 347 PortProvider* port_provider)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 return false; 399 return false;
389 } 400 }
390 401
391 meminfo->free = static_cast<int>( 402 meminfo->free = static_cast<int>(
392 (vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE / 1024); 403 (vm_info.free_count - vm_info.speculative_count) * PAGE_SIZE / 1024);
393 404
394 return true; 405 return true;
395 } 406 }
396 407
397 } // namespace base 408 } // namespace base
OLDNEW
« base/process/process_metrics.cc ('K') | « base/process/process_metrics.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698