| 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 }; |
| 282 |
| 283 // Checks whether the candidate string is a valid disk name, [sh]d[a-z]+ |
| 284 // for a generic disk or mmcblk[0-9]+ for the MMC case. |
| 285 // Names of disk partitions (e.g. sda1) are not valid. |
| 286 BASE_EXPORT bool IsValidDiskName(const std::string& candidate); |
| 287 |
| 288 // Retrieves data from /proc/diskstats about system-wide disk I/O. |
| 289 // Fills in the provided |diskinfo| structure. Returns true on success. |
| 290 BASE_EXPORT bool GetSystemDiskInfo(SystemDiskInfo* diskinfo); |
| 264 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 291 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 265 | 292 |
| 266 #if defined(OS_CHROMEOS) | 293 #if defined(OS_CHROMEOS) |
| 267 // Data from files in directory /sys/block/zram0 about ZRAM usage. | 294 // Data from files in directory /sys/block/zram0 about ZRAM usage. |
| 268 struct BASE_EXPORT SwapInfo { | 295 struct BASE_EXPORT SwapInfo { |
| 269 SwapInfo() | 296 SwapInfo() |
| 270 : num_reads(0), | 297 : num_reads(0), |
| 271 num_writes(0), | 298 num_writes(0), |
| 272 compr_data_size(0), | 299 compr_data_size(0), |
| 273 orig_data_size(0), | 300 orig_data_size(0), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 289 // Collects and holds performance metrics for system memory and disk. | 316 // Collects and holds performance metrics for system memory and disk. |
| 290 // Provides functionality to retrieve the data on various platforms and | 317 // Provides functionality to retrieve the data on various platforms and |
| 291 // to serialize the stored data. | 318 // to serialize the stored data. |
| 292 class SystemMetrics { | 319 class SystemMetrics { |
| 293 public: | 320 public: |
| 294 SystemMetrics() : committed_memory_(0) { } | 321 SystemMetrics() : committed_memory_(0) { } |
| 295 | 322 |
| 296 static SystemMetrics Sample(); | 323 static SystemMetrics Sample(); |
| 297 | 324 |
| 298 private: | 325 private: |
| 326 FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics); |
| 327 |
| 299 size_t committed_memory_; | 328 size_t committed_memory_; |
| 300 #if defined(OS_LINUX) || defined(OS_ANDROID) | 329 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 301 SystemMemoryInfoKB memory_info_; | 330 SystemMemoryInfoKB memory_info_; |
| 302 #endif | 331 #endif |
| 303 }; | 332 }; |
| 304 | 333 |
| 305 } // namespace base | 334 } // namespace base |
| 306 | 335 |
| 307 #endif // BASE_PROCESS_PROCESS_METRICS_H_ | 336 #endif // BASE_PROCESS_PROCESS_METRICS_H_ |
| OLD | NEW |