| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_INTERNAL_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ |
| 6 #define BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ | 6 #define BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ |
| 7 | 7 |
| 8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/sparse_histogram.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 | 13 |
| 13 // This is for macros internal to base/metrics. They should not be used outside | 14 // This is for macros internal to base/metrics. They should not be used outside |
| 14 // of this directory. For writing to UMA histograms, see histogram_macros.h. | 15 // of this directory. For writing to UMA histograms, see histogram_macros.h. |
| 15 | 16 |
| 16 // TODO(rkaplow): Improve commenting of these methods. | 17 // TODO(rkaplow): Improve commenting of these methods. |
| 17 | 18 |
| 18 //------------------------------------------------------------------------------ | 19 //------------------------------------------------------------------------------ |
| 19 // Histograms are often put in areas where they are called many many times, and | 20 // Histograms are often put in areas where they are called many many times, and |
| 20 // performance is critical. As a result, they are designed to have a very low | 21 // performance is critical. As a result, they are designed to have a very low |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ | 121 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ |
| 121 } else { \ | 122 } else { \ |
| 122 UMA_HISTOGRAM_TIMES(name, elapsed); \ | 123 UMA_HISTOGRAM_TIMES(name, elapsed); \ |
| 123 } \ | 124 } \ |
| 124 } \ | 125 } \ |
| 125 private: \ | 126 private: \ |
| 126 base::TimeTicks constructed_; \ | 127 base::TimeTicks constructed_; \ |
| 127 } scoped_histogram_timer_##key | 128 } scoped_histogram_timer_##key |
| 128 | 129 |
| 129 #endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ | 130 #endif // BASE_METRICS_HISTOGRAM_MACROS_INTERNAL_H_ |
| 131 |
| 132 // Macro for sparse histogram. |
| 133 // The implementation is more costly to add values to, and each value |
| 134 // stored has more overhead, compared to the other histogram types. However it |
| 135 // may be more efficient in memory if the total number of sample values is small |
| 136 // compared to the range of their values. |
| 137 #define INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample) \ |
| 138 do { \ |
| 139 base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( \ |
| 140 name, base::HistogramBase::kUmaTargetedHistogramFlag); \ |
| 141 histogram->Add(sample); \ |
| 142 } while (0) |
| OLD | NEW |