OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ |
6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ | 6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ |
7 | 7 |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/histogram_macros_internal.h" | 9 #include "base/metrics/histogram_macros_internal.h" |
10 #include "base/metrics/histogram_macros_local.h" | 10 #include "base/metrics/histogram_macros_local.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 base::HistogramBase::kUmaStabilityHistogramFlag) | 240 base::HistogramBase::kUmaStabilityHistogramFlag) |
241 | 241 |
242 //------------------------------------------------------------------------------ | 242 //------------------------------------------------------------------------------ |
243 // Sparse histograms. | 243 // Sparse histograms. |
244 | 244 |
245 // Sparse histograms are well suited for recording counts of exact sample values | 245 // Sparse histograms are well suited for recording counts of exact sample values |
246 // that are sparsely distributed over a large range. | 246 // that are sparsely distributed over a large range. |
247 // | 247 // |
248 // UMA_HISTOGRAM_SPARSE_SLOWLY is good for sparsely distributed and/or | 248 // UMA_HISTOGRAM_SPARSE_SLOWLY is good for sparsely distributed and/or |
249 // infrequently recorded values since the implementation is slower | 249 // infrequently recorded values since the implementation is slower |
250 // and takes more memory. | 250 // and takes more memory. For sparse data, sparse histograms have the advantage |
| 251 // of using less memory client-side, because they allocate buckets on demand |
| 252 // rather than preallocating. However, server-side, we still need to load all |
| 253 // buckets, across all users, at once. |
| 254 |
| 255 // Thus, please avoid exploding such histograms, i.e. uploading many many |
| 256 // distinct values to the server (across all users). Concretely, keep the number |
| 257 // of distinct values <= 100 at best, definitely <= 1000. If you have no |
| 258 // guarantees on the range of your data, use capping, e.g.: |
| 259 // UMA_HISTOGRAM_SPARSE_SLOWLY("MyHistogram", |
| 260 // std::max(0, std::min(200, value))); |
251 // | 261 // |
252 // For instance, Sqlite.Version.* are sparse because for any given database, | 262 // For instance, Sqlite.Version.* are sparse because for any given database, |
253 // there's going to be exactly one version logged. | 263 // there's going to be exactly one version logged. |
254 // The |sample| can be a negative or non-negative number. | 264 // The |sample| can be a negative or non-negative number. |
255 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ | 265 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
256 INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) | 266 INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) |
257 | 267 |
258 //------------------------------------------------------------------------------ | 268 //------------------------------------------------------------------------------ |
259 // Histogram instantiation helpers. | 269 // Histogram instantiation helpers. |
260 | 270 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the | 316 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the |
307 // requirement of |custom_ranges|. You can use the helper function | 317 // requirement of |custom_ranges|. You can use the helper function |
308 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid | 318 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid |
309 // sample values to a std::vector<int>. | 319 // sample values to a std::vector<int>. |
310 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 320 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
311 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 321 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
312 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 322 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
313 base::HistogramBase::kUmaTargetedHistogramFlag)) | 323 base::HistogramBase::kUmaTargetedHistogramFlag)) |
314 | 324 |
315 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 325 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |