| 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 <dirent.h> | 7 #include <dirent.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return internal::ReadProcStatsAndGetFieldAsSizeT(process_, internal::VM_RSS) * | 185 return internal::ReadProcStatsAndGetFieldAsSizeT(process_, internal::VM_RSS) * |
| 186 getpagesize(); | 186 getpagesize(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 // On linux, we return the high water mark of RSS. | 189 // On linux, we return the high water mark of RSS. |
| 190 size_t ProcessMetrics::GetPeakWorkingSetSize() const { | 190 size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
| 191 return ReadProcStatusAndGetFieldAsSizeT(process_, "VmHWM") * 1024; | 191 return ReadProcStatusAndGetFieldAsSizeT(process_, "VmHWM") * 1024; |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, | 194 bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, |
| 195 size_t* shared_bytes) { | 195 size_t* shared_bytes) const { |
| 196 WorkingSetKBytes ws_usage; | 196 WorkingSetKBytes ws_usage; |
| 197 if (!GetWorkingSetKBytes(&ws_usage)) | 197 if (!GetWorkingSetKBytes(&ws_usage)) |
| 198 return false; | 198 return false; |
| 199 | 199 |
| 200 if (private_bytes) | 200 if (private_bytes) |
| 201 *private_bytes = ws_usage.priv * 1024; | 201 *private_bytes = ws_usage.priv * 1024; |
| 202 | 202 |
| 203 if (shared_bytes) | 203 if (shared_bytes) |
| 204 *shared_bytes = ws_usage.shared * 1024; | 204 *shared_bytes = ws_usage.shared * 1024; |
| 205 | 205 |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 #if defined(OS_LINUX) | 966 #if defined(OS_LINUX) |
| 967 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 967 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
| 968 uint64_t wake_ups; | 968 uint64_t wake_ups; |
| 969 const char kWakeupStat[] = "se.statistics.nr_wakeups"; | 969 const char kWakeupStat[] = "se.statistics.nr_wakeups"; |
| 970 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? | 970 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? |
| 971 CalculateIdleWakeupsPerSecond(wake_ups) : 0; | 971 CalculateIdleWakeupsPerSecond(wake_ups) : 0; |
| 972 } | 972 } |
| 973 #endif // defined(OS_LINUX) | 973 #endif // defined(OS_LINUX) |
| 974 | 974 |
| 975 } // namespace base | 975 } // namespace base |
| OLD | NEW |