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

Side by Side Diff: base/process/process_metrics_linux.cc

Issue 2740423002: mac: Fix calulation for number of resident pages in a process. (Closed)
Patch Set: comments from mark. Created 3 years, 9 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
« no previous file with comments | « base/process/process_metrics_freebsd.cc ('k') | base/process/process_metrics_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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
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
OLDNEW
« no previous file with comments | « base/process/process_metrics_freebsd.cc ('k') | base/process/process_metrics_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698