OLD | NEW |
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 <sys/sysctl.h> | 10 #include <sys/sysctl.h> |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 if (last_absolute_idle_wakeups_ == 0) { | 306 if (last_absolute_idle_wakeups_ == 0) { |
307 // First call, just set the last values. | 307 // First call, just set the last values. |
308 last_idle_wakeups_time_ = time; | 308 last_idle_wakeups_time_ = time; |
309 last_absolute_idle_wakeups_ = absolute_idle_wakeups; | 309 last_absolute_idle_wakeups_ = absolute_idle_wakeups; |
310 return 0; | 310 return 0; |
311 } | 311 } |
312 | 312 |
313 int64 wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_; | 313 int64 wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_; |
314 int64 time_delta = (time - last_idle_wakeups_time_).InMicroseconds(); | 314 int64 time_delta = (time - last_idle_wakeups_time_).InMicroseconds(); |
315 DCHECK_NE(0U, time_delta); | 315 if (time_delta == 0) { |
316 if (time_delta == 0) | 316 NOTREACHED(); |
317 return 0; | 317 return 0; |
| 318 } |
318 | 319 |
319 last_idle_wakeups_time_ = time; | 320 last_idle_wakeups_time_ = time; |
320 last_absolute_idle_wakeups_ = absolute_idle_wakeups; | 321 last_absolute_idle_wakeups_ = absolute_idle_wakeups; |
321 | 322 |
322 // Round to average wakeups per second. | 323 // Round to average wakeups per second. |
323 const int kMicrosecondsPerSecond = 1000 * 1000; | 324 const int kMicrosecondsPerSecond = 1000 * 1000; |
324 return (wakeups_delta * kMicrosecondsPerSecond + time_delta/2) / time_delta; | 325 return (wakeups_delta * kMicrosecondsPerSecond + time_delta/2) / time_delta; |
325 } | 326 } |
326 | 327 |
327 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { | 328 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { |
(...skipping 28 matching lines...) Expand all Loading... |
356 &count); | 357 &count); |
357 if (kr != KERN_SUCCESS) { | 358 if (kr != KERN_SUCCESS) { |
358 MACH_DLOG(WARNING, kr) << "host_statistics"; | 359 MACH_DLOG(WARNING, kr) << "host_statistics"; |
359 return 0; | 360 return 0; |
360 } | 361 } |
361 | 362 |
362 return (data.active_count * PAGE_SIZE) / 1024; | 363 return (data.active_count * PAGE_SIZE) / 1024; |
363 } | 364 } |
364 | 365 |
365 } // namespace base | 366 } // namespace base |
OLD | NEW |