| Index: base/process/process_metrics_mac.cc
|
| diff --git a/base/process/process_metrics_mac.cc b/base/process/process_metrics_mac.cc
|
| index 61db9c2cadf585ff8512ff9ecccc3e3c29fe8bb5..6227ca2c67c4597df708a84d6a3b3e8c03185259 100644
|
| --- a/base/process/process_metrics_mac.cc
|
| +++ b/base/process/process_metrics_mac.cc
|
| @@ -267,31 +267,26 @@ double ProcessMetrics::GetCPUUsage() {
|
| timeradd(&user_timeval, &task_timeval, &task_timeval);
|
| timeradd(&system_timeval, &task_timeval, &task_timeval);
|
|
|
| - struct timeval now;
|
| - int retval = gettimeofday(&now, NULL);
|
| - if (retval)
|
| - return 0;
|
| -
|
| - int64 time = TimeValToMicroseconds(now);
|
| + TimeTicks time = TimeTicks::Now();
|
| int64 task_time = TimeValToMicroseconds(task_timeval);
|
|
|
| - if (last_cpu_time_ == 0) {
|
| + if (last_system_time_ == 0) {
|
| // First call, just set the last values.
|
| - last_cpu_time_ = time;
|
| + last_cpu_walltime_ = time;
|
| last_system_time_ = task_time;
|
| return 0;
|
| }
|
|
|
| int64 system_time_delta = task_time - last_system_time_;
|
| - int64 time_delta = time - last_cpu_time_;
|
| - DCHECK_NE(0U, time_delta);
|
| - if (time_delta == 0)
|
| + int64 walltime_delta = (time - last_cpu_walltime_).InMicroseconds();
|
| + DCHECK_NE(0U, walltime_delta);
|
| + if (walltime_delta == 0)
|
| return 0;
|
|
|
| - last_cpu_time_ = time;
|
| + last_cpu_walltime_ = time;
|
| last_system_time_ = task_time;
|
|
|
| - return static_cast<double>(system_time_delta * 100.0) / time_delta;
|
| + return static_cast<double>(system_time_delta * 100.0) / walltime_delta;
|
| }
|
|
|
| int ProcessMetrics::GetIdleWakeupsPerSecond() {
|
| @@ -314,32 +309,28 @@ int ProcessMetrics::GetIdleWakeupsPerSecond() {
|
| }
|
| uint64_t absolute_idle_wakeups = power_info_data.task_platform_idle_wakeups;
|
|
|
| - struct timeval now;
|
| - int retval = gettimeofday(&now, NULL);
|
| - if (retval)
|
| - return 0;
|
| -
|
| - int64 time = TimeValToMicroseconds(now);
|
| + TimeTicks time = TimeTicks::Now();
|
|
|
| - if (last_idle_wakeups_time_ == 0) {
|
| + if (last_absolute_idle_wakeups_ == 0) {
|
| // First call, just set the last values.
|
| - last_idle_wakeups_time_ = time;
|
| + last_idle_wakeups_walltime_ = time;
|
| last_absolute_idle_wakeups_ = absolute_idle_wakeups;
|
| return 0;
|
| }
|
|
|
| int64 wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_;
|
| - int64 time_delta = time - last_idle_wakeups_time_;
|
| - DCHECK_NE(0U, time_delta);
|
| - if (time_delta == 0)
|
| + int64 walltime_delta = (time - last_idle_wakeups_walltime_).InMicroseconds();
|
| + DCHECK_NE(0U, walltime_delta);
|
| + if (walltime_delta == 0)
|
| return 0;
|
|
|
| - last_idle_wakeups_time_ = time;
|
| + last_idle_wakeups_walltime_ = time;
|
| last_absolute_idle_wakeups_ = absolute_idle_wakeups;
|
|
|
| // Round to average wakeups per second.
|
| const int kMicrosecondsPerSecond = 1000 * 1000;
|
| - return (wakeups_delta * kMicrosecondsPerSecond + time_delta/2) / time_delta;
|
| + return (wakeups_delta * kMicrosecondsPerSecond + walltime_delta / 2) /
|
| + walltime_delta;
|
| }
|
|
|
| bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const {
|
| @@ -349,9 +340,7 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const {
|
| ProcessMetrics::ProcessMetrics(ProcessHandle process,
|
| ProcessMetrics::PortProvider* port_provider)
|
| : process_(process),
|
| - last_cpu_time_(0),
|
| last_system_time_(0),
|
| - last_idle_wakeups_time_(0),
|
| last_absolute_idle_wakeups_(0),
|
| port_provider_(port_provider) {
|
| processor_count_ = SysInfo::NumberOfProcessors();
|
|
|