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 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Fills a WorkingSetKBytes containing resident private and shared memory | 153 // Fills a WorkingSetKBytes containing resident private and shared memory |
154 // usage in bytes, as per definition of WorkingSetBytes. | 154 // usage in bytes, as per definition of WorkingSetBytes. |
155 bool GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const; | 155 bool GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const; |
156 | 156 |
157 // Computes the current process available memory for allocation. | 157 // Computes the current process available memory for allocation. |
158 // It does a linear scan of the address space querying each memory region | 158 // It does a linear scan of the address space querying each memory region |
159 // for its free (unallocated) status. It is useful for estimating the memory | 159 // for its free (unallocated) status. It is useful for estimating the memory |
160 // load and fragmentation. | 160 // load and fragmentation. |
161 bool CalculateFreeMemory(FreeMBytes* free) const; | 161 bool CalculateFreeMemory(FreeMBytes* free) const; |
162 | 162 |
163 // Returns the CPU usage in percent since the last time this method was | 163 // Returns the CPU usage in percent since the last time this method or |
164 // called. The first time this method is called it returns 0 and will return | 164 // GetPlatformIndependentCPUUsage() was called. The first time this method |
165 // the actual CPU info on subsequent calls. | 165 // is called it returns 0 and will return the actual CPU info on subsequent |
166 // On Windows, the CPU usage value is for all CPUs. So if you have 2 CPUs and | 166 // calls. On Windows, the CPU usage value is for all CPUs. So if you have |
167 // your process is using all the cycles of 1 CPU and not the other CPU, this | 167 // 2 CPUs and your process is using all the cycles of 1 CPU and not the other |
168 // method returns 50. | 168 // CPU, this method returns 50. |
169 double GetCPUUsage(); | 169 double GetCPUUsage(); |
170 | 170 |
| 171 // Same as GetCPUUsage(), but will return consistent values on all platforms |
| 172 // (cancelling the Windows exception mentioned above) by returning a value in |
| 173 // the range of 0 to (100 * numCPUCores) everywhere. |
| 174 double GetPlatformIndependentCPUUsage(); |
| 175 |
171 // Retrieves accounting information for all I/O operations performed by the | 176 // Retrieves accounting information for all I/O operations performed by the |
172 // process. | 177 // process. |
173 // If IO information is retrieved successfully, the function returns true | 178 // If IO information is retrieved successfully, the function returns true |
174 // and fills in the IO_COUNTERS passed in. The function returns false | 179 // and fills in the IO_COUNTERS passed in. The function returns false |
175 // otherwise. | 180 // otherwise. |
176 bool GetIOCounters(IoCounters* io_counters) const; | 181 bool GetIOCounters(IoCounters* io_counters) const; |
177 | 182 |
178 private: | 183 private: |
179 #if !defined(OS_MACOSX) || defined(OS_IOS) | 184 #if !defined(OS_MACOSX) || defined(OS_IOS) |
180 explicit ProcessMetrics(ProcessHandle process); | 185 explicit ProcessMetrics(ProcessHandle process); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 SystemDiskInfo disk_info_; | 361 SystemDiskInfo disk_info_; |
357 #endif | 362 #endif |
358 #if defined(OS_CHROMEOS) | 363 #if defined(OS_CHROMEOS) |
359 SwapInfo swap_info_; | 364 SwapInfo swap_info_; |
360 #endif | 365 #endif |
361 }; | 366 }; |
362 | 367 |
363 } // namespace base | 368 } // namespace base |
364 | 369 |
365 #endif // BASE_PROCESS_PROCESS_METRICS_H_ | 370 #endif // BASE_PROCESS_PROCESS_METRICS_H_ |
OLD | NEW |