OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/chromeos/memory/system_memory_stats_recorder.h" | 5 #include "chrome/browser/memory/system_memory_stats_recorder.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/process/process_metrics.h" | 8 #include "base/process/process_metrics.h" |
9 | 9 |
| 10 namespace memory { |
| 11 |
10 // Record a size in megabytes, over a potential interval up to 32 GB. | 12 // Record a size in megabytes, over a potential interval up to 32 GB. |
11 #define UMA_HISTOGRAM_AVAILABLE_MEGABYTES(name, sample) \ | 13 #define UMA_HISTOGRAM_AVAILABLE_MEGABYTES(name, sample) \ |
12 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 32768, 50) | 14 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 32768, 50) |
13 | 15 |
14 // Record a size in megabytes, a potential interval from 250MB up to | 16 // Record a size in megabytes, a potential interval from 250MB up to |
15 // 32 GB. | 17 // 32 GB. |
16 #define UMA_HISTOGRAM_ALLOCATED_MEGABYTES(name, sample) \ | 18 #define UMA_HISTOGRAM_ALLOCATED_MEGABYTES(name, sample) \ |
17 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 250, 32768, 50) | 19 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 250, 32768, 50) |
18 | 20 |
19 // Records a statistics |sample| for UMA histogram |name| | 21 // Records a statistics |sample| for UMA histogram |name| |
20 // using a linear distribution of buckets. | 22 // using a linear distribution of buckets. |
21 #define UMA_HISTOGRAM_LINEAR(name, sample, max, buckets) \ | 23 #define UMA_HISTOGRAM_LINEAR(name, sample, max, buckets) \ |
22 STATIC_HISTOGRAM_POINTER_BLOCK( \ | 24 STATIC_HISTOGRAM_POINTER_BLOCK( \ |
23 name, Add(sample), \ | 25 name, Add(sample), \ |
24 base::LinearHistogram::FactoryGet( \ | 26 base::LinearHistogram::FactoryGet( \ |
25 name, \ | 27 name, \ |
26 1, /* Minimum. The 0 bin for underflow is automatically added. */ \ | 28 1, /* Minimum. The 0 bin for underflow is automatically added. */ \ |
27 max + 1, /* Ensure bucket size of |maximum| / |bucket_count|. */ \ | 29 max + 1, /* Ensure bucket size of |maximum| / |bucket_count|. */ \ |
28 buckets + 2, /* Account for the underflow and overflow bins. */ \ | 30 buckets + 2, /* Account for the underflow and overflow bins. */ \ |
29 base::Histogram::kUmaTargetedHistogramFlag)) | 31 base::Histogram::kUmaTargetedHistogramFlag)) |
30 | 32 |
31 #define UMA_HISTOGRAM_MEGABYTES_LINEAR(name, sample) \ | 33 #define UMA_HISTOGRAM_MEGABYTES_LINEAR(name, sample) \ |
32 UMA_HISTOGRAM_LINEAR(name, sample, 2500, 50) | 34 UMA_HISTOGRAM_LINEAR(name, sample, 2500, 50) |
33 | 35 |
34 namespace chromeos { | |
35 | |
36 void RecordMemoryStats(RecordMemoryStatsType type) { | 36 void RecordMemoryStats(RecordMemoryStatsType type) { |
37 base::SystemMemoryInfoKB memory; | 37 base::SystemMemoryInfoKB memory; |
38 if (!base::GetSystemMemoryInfo(&memory)) | 38 if (!base::GetSystemMemoryInfo(&memory)) |
39 return; | 39 return; |
40 // Record graphics GEM object size in a histogram with 50 MB buckets. | 40 // Record graphics GEM object size in a histogram with 50 MB buckets. |
41 int mem_graphics_gem_mb = 0; | 41 int mem_graphics_gem_mb = 0; |
42 if (memory.gem_size != -1) | 42 if (memory.gem_size != -1) |
43 mem_graphics_gem_mb = memory.gem_size / 1024 / 1024; | 43 mem_graphics_gem_mb = memory.gem_size / 1024 / 1024; |
44 | 44 |
45 // Record shared memory (used by renderer/GPU buffers). | 45 // Record shared memory (used by renderer/GPU buffers). |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 mem_shmem_mb); | 84 mem_shmem_mb); |
85 UMA_HISTOGRAM_ALLOCATED_MEGABYTES( | 85 UMA_HISTOGRAM_ALLOCATED_MEGABYTES( |
86 "Memory.OOMKill.Extensions.MemAllocatedMB", mem_allocated_mb); | 86 "Memory.OOMKill.Extensions.MemAllocatedMB", mem_allocated_mb); |
87 UMA_HISTOGRAM_AVAILABLE_MEGABYTES( | 87 UMA_HISTOGRAM_AVAILABLE_MEGABYTES( |
88 "Memory.OOMKill.Extensions.MemAvailableMB", mem_available_mb); | 88 "Memory.OOMKill.Extensions.MemAvailableMB", mem_available_mb); |
89 break; | 89 break; |
90 } | 90 } |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 } // namespace chromeos | 94 } // namespace memory |
OLD | NEW |