histogram_iter.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #include "histogram_iter.h"
  2. #include <contrib/libs/hdr_histogram/src/hdr_histogram.h>
  3. namespace NHdr {
  4. // TBaseHistogramIterator -----------------------------------------------------
  5. TBaseHistogramIterator::TBaseHistogramIterator()
  6. : Iter_(new hdr_iter)
  7. {
  8. }
  9. TBaseHistogramIterator::~TBaseHistogramIterator() {
  10. }
  11. bool TBaseHistogramIterator::Next() {
  12. return hdr_iter_next(Iter_.Get());
  13. }
  14. i32 TBaseHistogramIterator::GetCountsIndex() const {
  15. return Iter_->counts_index;
  16. }
  17. i32 TBaseHistogramIterator::GetTotalCount() const {
  18. return Iter_->total_count;
  19. }
  20. i64 TBaseHistogramIterator::GetCount() const {
  21. return Iter_->count;
  22. }
  23. i64 TBaseHistogramIterator::GetCumulativeCount() const {
  24. return Iter_->cumulative_count;
  25. }
  26. i64 TBaseHistogramIterator::GetValue() const {
  27. return Iter_->value;
  28. }
  29. i64 TBaseHistogramIterator::GetHighestEquivalentValue() const {
  30. return Iter_->highest_equivalent_value;
  31. }
  32. i64 TBaseHistogramIterator::GetLowestEquivalentValue() const {
  33. return Iter_->lowest_equivalent_value;
  34. }
  35. i64 TBaseHistogramIterator::GetMedianEquivalentValue() const {
  36. return Iter_->median_equivalent_value;
  37. }
  38. i64 TBaseHistogramIterator::GetValueIteratedFrom() const {
  39. return Iter_->value_iterated_from;
  40. }
  41. i64 TBaseHistogramIterator::GetValueIteratedTo() const {
  42. return Iter_->value_iterated_to;
  43. }
  44. // TAllValuesIterator ---------------------------------------------------------
  45. TAllValuesIterator::TAllValuesIterator(const THistogram& histogram) {
  46. hdr_iter_init(Iter_.Get(), histogram.GetHdrHistogramImpl());
  47. }
  48. // TRecordedValuesIterator ----------------------------------------------------
  49. TRecordedValuesIterator::TRecordedValuesIterator(const THistogram& histogram) {
  50. hdr_iter_recorded_init(Iter_.Get(), histogram.GetHdrHistogramImpl());
  51. }
  52. i64 TRecordedValuesIterator::GetCountAddedInThisIterationStep() const {
  53. return Iter_->specifics.recorded.count_added_in_this_iteration_step;
  54. }
  55. // TPercentileIterator --------------------------------------------------------
  56. TPercentileIterator::TPercentileIterator(
  57. const THistogram& histogram, ui32 ticksPerHalfDistance) {
  58. hdr_iter_percentile_init(
  59. Iter_.Get(), histogram.GetHdrHistogramImpl(),
  60. ticksPerHalfDistance);
  61. }
  62. i32 TPercentileIterator::GetTicketsPerHalfDistance() const {
  63. return Iter_->specifics.percentiles.ticks_per_half_distance;
  64. }
  65. double TPercentileIterator::GetPercentileToIterateTo() const {
  66. return Iter_->specifics.percentiles.percentile_to_iterate_to;
  67. }
  68. double TPercentileIterator::GetPercentile() const {
  69. return Iter_->specifics.percentiles.percentile;
  70. }
  71. // TLinearIterator ------------------------------------------------------------
  72. TLinearIterator::TLinearIterator(
  73. const THistogram& histogram, i64 valueUnitsPerBucket) {
  74. hdr_iter_linear_init(
  75. Iter_.Get(), histogram.GetHdrHistogramImpl(), valueUnitsPerBucket);
  76. }
  77. i64 TLinearIterator::GetValueUnitsPerBucket() const {
  78. return Iter_->specifics.linear.value_units_per_bucket;
  79. }
  80. i64 TLinearIterator::GetCountAddedInThisIterationStep() const {
  81. return Iter_->specifics.linear.count_added_in_this_iteration_step;
  82. }
  83. i64 TLinearIterator::GetNextValueReportingLevel() const {
  84. return Iter_->specifics.linear.next_value_reporting_level;
  85. }
  86. i64 TLinearIterator::GetNextValueReportingLevelLowestEquivalent() const {
  87. return Iter_->specifics.linear.next_value_reporting_level_lowest_equivalent;
  88. }
  89. // TLogarithmicIterator -------------------------------------------------------
  90. TLogarithmicIterator::TLogarithmicIterator(
  91. const THistogram& histogram, i64 valueUnitsInFirstBucket,
  92. double logBase) {
  93. hdr_iter_log_init(
  94. Iter_.Get(), histogram.GetHdrHistogramImpl(),
  95. valueUnitsInFirstBucket, logBase);
  96. }
  97. double TLogarithmicIterator::GetLogBase() const {
  98. return Iter_->specifics.log.log_base;
  99. }
  100. i64 TLogarithmicIterator::GetCountAddedInThisIterationStep() const {
  101. return Iter_->specifics.log.count_added_in_this_iteration_step;
  102. }
  103. i64 TLogarithmicIterator::GetNextValueReportingLevel() const {
  104. return Iter_->specifics.log.next_value_reporting_level;
  105. }
  106. i64 TLogarithmicIterator::GetNextValueReportingLevelLowestEquivalent() const {
  107. return Iter_->specifics.log.next_value_reporting_level_lowest_equivalent;
  108. }
  109. }