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

Side by Side Diff: base/process/process_metrics.h

Issue 888193002: ProcessMetrics::GetCPUUsage() is Slow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 // This file contains routines for gathering resource statistics for processes 5 // This file contains routines for gathering resource statistics for processes
6 // running on the system. 6 // running on the system.
7 7
8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_ 8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_
9 #define BASE_PROCESS_PROCESS_METRICS_H_ 9 #define BASE_PROCESS_PROCESS_METRICS_H_
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // limit, whichever is lower. 240 // limit, whichever is lower.
241 BASE_EXPORT void SetFdLimit(unsigned int max_descriptors); 241 BASE_EXPORT void SetFdLimit(unsigned int max_descriptors);
242 #endif // defined(OS_POSIX) 242 #endif // defined(OS_POSIX)
243 243
244 #if defined(OS_LINUX) || defined(OS_ANDROID) 244 #if defined(OS_LINUX) || defined(OS_ANDROID)
245 // Parse the data found in /proc/<pid>/stat and return the sum of the 245 // Parse the data found in /proc/<pid>/stat and return the sum of the
246 // CPU-related ticks. Returns -1 on parse error. 246 // CPU-related ticks. Returns -1 on parse error.
247 // Exposed for testing. 247 // Exposed for testing.
248 BASE_EXPORT int ParseProcStatCPU(const std::string& input); 248 BASE_EXPORT int ParseProcStatCPU(const std::string& input);
249 249
250 // Extract the sum of the CPU-related ticks from the given |input| which
251 // contains the stats found in /proc/<pid>/stat. Returns -1 on error.
252 //
253 // Use this version instead of the above for faster results.
254 //
255 // Exposed for testing.
256 BASE_EXPORT int GetCpuFromProcStats(const std::string& input);
danakj 2015/02/03 18:51:09 why are you adding a new method with the same retu
afakhry 2015/02/03 20:23:54 I wanted to keep the old one for reference, but yo
257
250 // Get the number of threads of |process| as available in /proc/<pid>/stat. 258 // Get the number of threads of |process| as available in /proc/<pid>/stat.
251 // This should be used with care as no synchronization with running threads is 259 // This should be used with care as no synchronization with running threads is
252 // done. This is mostly useful to guarantee being single-threaded. 260 // done. This is mostly useful to guarantee being single-threaded.
253 // Returns 0 on failure. 261 // Returns 0 on failure.
254 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process); 262 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process);
255 263
256 // /proc/self/exe refers to the current executable. 264 // /proc/self/exe refers to the current executable.
257 BASE_EXPORT extern const char kProcSelfExe[]; 265 BASE_EXPORT extern const char kProcSelfExe[];
258 266
259 // Data from /proc/meminfo about system-wide memory consumption. 267 // Data from /proc/meminfo about system-wide memory consumption.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 SystemDiskInfo disk_info_; 391 SystemDiskInfo disk_info_;
384 #endif 392 #endif
385 #if defined(OS_CHROMEOS) 393 #if defined(OS_CHROMEOS)
386 SwapInfo swap_info_; 394 SwapInfo swap_info_;
387 #endif 395 #endif
388 }; 396 };
389 397
390 } // namespace base 398 } // namespace base
391 399
392 #endif // BASE_PROCESS_PROCESS_METRICS_H_ 400 #endif // BASE_PROCESS_PROCESS_METRICS_H_
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics_linux.cc » ('j') | base/process/process_metrics_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698