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 // 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 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/gtest_prod_util.h" | |
15 #include "base/process/process_handle.h" | 16 #include "base/process/process_handle.h" |
16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
17 | 18 |
18 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
19 #include <mach/mach.h> | 20 #include <mach/mach.h> |
20 #endif | 21 #endif |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 | 24 |
24 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 | 255 |
255 // Gem data will be -1 if not supported. | 256 // Gem data will be -1 if not supported. |
256 int gem_objects; | 257 int gem_objects; |
257 long long gem_size; | 258 long long gem_size; |
258 }; | 259 }; |
259 | 260 |
260 // Retrieves data from /proc/meminfo about system-wide memory consumption. | 261 // Retrieves data from /proc/meminfo about system-wide memory consumption. |
261 // Fills in the provided |meminfo| structure. Returns true on success. | 262 // Fills in the provided |meminfo| structure. Returns true on success. |
262 // Exposed for memory debugging widget. | 263 // Exposed for memory debugging widget. |
263 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); | 264 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); |
265 | |
266 // Data from /proc/diskstats about system-wide disk I/O. | |
267 struct BASE_EXPORT SystemDiskInfo { | |
268 SystemDiskInfo(); | |
269 | |
270 uint64 reads; | |
271 uint64 reads_merged; | |
272 uint64 sectors_read; | |
273 uint64 read_time; | |
274 uint64 writes; | |
275 uint64 writes_merged; | |
276 uint64 sectors_written; | |
277 uint64 write_time; | |
278 uint64 io; | |
279 uint64 io_time; | |
280 uint64 weighted_io_time; | |
281 uint64 bytes_read_per_sec; | |
282 uint64 bytes_written_per_sec; | |
283 }; | |
284 | |
285 // Checks whether the candidate string is a valid disk name, [sh]d[a-z]+ | |
286 // for a generic disk or mmcblk[0-9]+ for the MMC case. | |
287 // Names of disk partitions (e.g. sda1) are not valid. | |
288 BASE_EXPORT bool ValidDiskName(const std::string& candidate); | |
darin (slow to review)
2013/08/24 05:49:05
nit: this needs a verb. IsValidDiskName or Validat
jwmak
2013/08/26 07:47:24
Done.
| |
289 | |
290 // Retrieves data from /proc/diskstats about system-wide disk I/O. | |
291 // Fills in the provided |diskinfo| structure. Returns true on success. | |
292 BASE_EXPORT bool GetSystemDiskInfo(SystemDiskInfo* diskinfo); | |
264 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 293 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
265 | 294 |
266 #if defined(OS_CHROMEOS) | 295 #if defined(OS_CHROMEOS) |
267 // Data from files in directory /sys/block/zram0 about ZRAM usage. | 296 // Data from files in directory /sys/block/zram0 about ZRAM usage. |
268 struct BASE_EXPORT SwapInfo { | 297 struct BASE_EXPORT SwapInfo { |
269 SwapInfo() | 298 SwapInfo() |
270 : num_reads(0), | 299 : num_reads(0), |
271 num_writes(0), | 300 num_writes(0), |
272 compr_data_size(0), | 301 compr_data_size(0), |
273 orig_data_size(0), | 302 orig_data_size(0), |
(...skipping 15 matching lines...) Expand all Loading... | |
289 // Collects and holds performance metrics for system memory and disk. | 318 // Collects and holds performance metrics for system memory and disk. |
290 // Provides functionality to retrieve the data on various platforms and | 319 // Provides functionality to retrieve the data on various platforms and |
291 // to serialize the stored data. | 320 // to serialize the stored data. |
292 class SystemMetrics { | 321 class SystemMetrics { |
293 public: | 322 public: |
294 SystemMetrics() : committed_memory_(0) { } | 323 SystemMetrics() : committed_memory_(0) { } |
295 | 324 |
296 static SystemMetrics Sample(); | 325 static SystemMetrics Sample(); |
297 | 326 |
298 private: | 327 private: |
328 FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics); | |
329 | |
299 size_t committed_memory_; | 330 size_t committed_memory_; |
300 #if defined(OS_LINUX) || defined(OS_ANDROID) | 331 #if defined(OS_LINUX) || defined(OS_ANDROID) |
301 SystemMemoryInfoKB memory_info_; | 332 SystemMemoryInfoKB memory_info_; |
302 #endif | 333 #endif |
303 }; | 334 }; |
304 | 335 |
305 } // namespace base | 336 } // namespace base |
306 | 337 |
307 #endif // BASE_PROCESS_PROCESS_METRICS_H_ | 338 #endif // BASE_PROCESS_PROCESS_METRICS_H_ |
OLD | NEW |