histogram_macros_local.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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
  3. // found in the LICENSE file.
  4. #ifndef BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_
  5. #define BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_
  6. #include "base/logging.h"
  7. #include "base/metrics/histogram.h"
  8. #include "base/metrics/histogram_macros_internal.h"
  9. #include "base/time/time.h"
  10. // TODO(rkaplow): Migrate all LOCAL_* usage within Chromium to include this
  11. // file instead of the histogram_macros.h file.
  12. //------------------------------------------------------------------------------
  13. // Enumeration histograms.
  14. //
  15. // For usage details, see the equivalents in histogram_macros.h.
  16. #define LOCAL_HISTOGRAM_ENUMERATION(name, ...) \
  17. INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \
  18. __VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \
  19. INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY) \
  20. (name, __VA_ARGS__, base::HistogramBase::kNoFlags)
  21. #define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \
  22. STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \
  23. base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags))
  24. //------------------------------------------------------------------------------
  25. // Percentage histograms.
  26. //
  27. // For usage details, see the equivalents in histogram_macros.h
  28. #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \
  29. LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101)
  30. //------------------------------------------------------------------------------
  31. // Count histograms. These are used for collecting numeric data. Note that we
  32. // have macros for more specialized use cases below (memory, time, percentages).
  33. // For usage details, see the equivalents in histogram_macros.h.
  34. #define LOCAL_HISTOGRAM_COUNTS_100(name, sample) \
  35. LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50)
  36. #define LOCAL_HISTOGRAM_COUNTS_10000(name, sample) \
  37. LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50)
  38. #define LOCAL_HISTOGRAM_COUNTS_1000000(name, sample) \
  39. LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50)
  40. #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \
  41. INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \
  42. name, sample, min, max, bucket_count, base::HistogramBase::kNoFlags)
  43. //------------------------------------------------------------------------------
  44. // Timing histograms. These are used for collecting timing data (generally
  45. // latencies).
  46. //
  47. // For usage details, see the equivalents in histogram_macros.h.
  48. #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \
  49. name, sample, base::TimeDelta::FromMilliseconds(1), \
  50. base::TimeDelta::FromSeconds(10), 50)
  51. #define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
  52. STATIC_HISTOGRAM_POINTER_BLOCK( \
  53. name, AddTimeMillisecondsGranularity(sample), \
  54. base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \
  55. base::HistogramBase::kNoFlags))
  56. //------------------------------------------------------------------------------
  57. // Memory histograms.
  58. //
  59. // For usage details, see the equivalents in histogram_macros.h.
  60. #define LOCAL_HISTOGRAM_MEMORY_KB(name, sample) LOCAL_HISTOGRAM_CUSTOM_COUNTS( \
  61. name, sample, 1000, 500000, 50)
  62. //------------------------------------------------------------------------------
  63. // Deprecated histograms. Not recommended for current use.
  64. // TODO(rkaplow): See if we can clean up this macro and usage.
  65. // Legacy non-explicit version. We suggest using LOCAL_HISTOGRAM_COUNTS_1000000
  66. // instead.
  67. #define LOCAL_HISTOGRAM_COUNTS(name, sample) \
  68. LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50)
  69. #endif // BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_