histogram_macros_local.h 4.1 KB

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