Lines Matching refs:iter
599 struct hdr_iter iter;
601 hdr_iter_recorded_init(&iter, from);
603 while (hdr_iter_next(&iter))
605 int64_t value = iter.value;
606 int64_t count = iter.count;
620 struct hdr_iter iter;
622 hdr_iter_recorded_init(&iter, from);
624 while (hdr_iter_next(&iter))
626 int64_t value = iter.value;
627 int64_t count = iter.count;
707 struct hdr_iter iter;
719 hdr_iter_init(&iter, h);
722 while (hdr_iter_next(&iter) && at_pos < length)
724 total += iter.count;
727 values[at_pos] = highest_equivalent_value(h, iter.value);
736 struct hdr_iter iter;
740 hdr_iter_init(&iter, h);
742 while (hdr_iter_next(&iter) && count < total_count)
744 if (0 != iter.count)
746 count += iter.count;
747 total += iter.count * hdr_median_equivalent_value(h, iter.value);
759 struct hdr_iter iter;
760 hdr_iter_init(&iter, h);
762 while (hdr_iter_next(&iter))
764 if (0 != iter.count)
766 double dev = (hdr_median_equivalent_value(h, iter.value) * 1.0) - mean;
767 geometric_dev_total += (dev * dev) * iter.count;
804 static bool has_buckets(struct hdr_iter* iter)
806 return iter->counts_index < iter->h->counts_len;
809 static bool has_next(struct hdr_iter* iter)
811 return iter->cumulative_count < iter->total_count;
814 static bool move_next(struct hdr_iter* iter)
816 iter->counts_index++;
818 if (!has_buckets(iter))
823 iter->count = counts_get_normalised(iter->h, iter->counts_index);
824 iter->cumulative_count += iter->count;
825 const int64_t value = hdr_value_at_index(iter->h, iter->counts_index);
826 const int32_t bucket_index = get_bucket_index(iter->h, value);
827 const int32_t sub_bucket_index = get_sub_bucket_index(value, bucket_index, iter->h->unit_magnitude);
828 const int64_t leq = lowest_equivalent_value_given_bucket_indices(iter->h, bucket_index, sub_bucket_index);
830 iter->h, bucket_index, sub_bucket_index);
831 iter->lowest_equivalent_value = leq;
832 iter->value = value;
833 iter->highest_equivalent_value = leq + size_of_equivalent_value_range - 1;
834 iter->median_equivalent_value = leq + (size_of_equivalent_value_range >> 1);
839 static int64_t peek_next_value_from_index(struct hdr_iter* iter)
841 return hdr_value_at_index(iter->h, iter->counts_index + 1);
845 struct hdr_iter *iter, int64_t reporting_level_upper_bound)
847 if (iter->counts_index >= iter->h->counts_len)
852 return peek_next_value_from_index(iter) > reporting_level_upper_bound;
855 static bool basic_iter_next(struct hdr_iter *iter)
857 if (!has_next(iter) || iter->counts_index >= iter->h->counts_len)
862 move_next(iter);
867 static void update_iterated_values(struct hdr_iter* iter, int64_t new_value_iterated_to)
869 iter->value_iterated_from = iter->value_iterated_to;
870 iter->value_iterated_to = new_value_iterated_to;
873 static bool all_values_iter_next(struct hdr_iter* iter)
875 bool result = move_next(iter);
879 update_iterated_values(iter, iter->value);
885 void hdr_iter_init(struct hdr_iter* iter, const struct hdr_histogram* h)
887 iter->h = h;
889 iter->counts_index = -1;
890 iter->total_count = h->total_count;
891 iter->count = 0;
892 iter->cumulative_count = 0;
893 iter->value = 0;
894 iter->highest_equivalent_value = 0;
895 iter->value_iterated_from = 0;
896 iter->value_iterated_to = 0;
898 iter->_next_fp = all_values_iter_next;
901 bool hdr_iter_next(struct hdr_iter* iter)
903 return iter->_next_fp(iter);
914 static bool percentile_iter_next(struct hdr_iter* iter)
918 struct hdr_iter_percentiles* percentiles = &iter->specifics.percentiles;
920 if (!has_next(iter))
933 if (iter->counts_index == -1 && !basic_iter_next(iter))
940 double current_percentile = (100.0 * (double) iter->cumulative_count) / iter->h->total_count;
941 if (iter->count != 0 &&
944 update_iterated_values(iter, highest_equivalent_value(iter->h, iter->value));
955 while (basic_iter_next(iter));
960 void hdr_iter_percentile_init(struct hdr_iter* iter, const struct hdr_histogram* h, int32_t ticks_per_half_distance)
962 iter->h = h;
964 hdr_iter_init(iter, h);
966 iter->specifics.percentiles.seen_last_value = false;
967 iter->specifics.percentiles.ticks_per_half_distance = ticks_per_half_distance;
968 iter->specifics.percentiles.percentile_to_iterate_to = 0.0;
969 iter->specifics.percentiles.percentile = 0.0;
971 iter->_next_fp = percentile_iter_next;
1010 static bool recorded_iter_next(struct hdr_iter* iter)
1012 while (basic_iter_next(iter))
1014 if (iter->count != 0)
1016 update_iterated_values(iter, iter->value);
1018 iter->specifics.recorded.count_added_in_this_iteration_step = iter->count;
1026 void hdr_iter_recorded_init(struct hdr_iter* iter, const struct hdr_histogram* h)
1028 hdr_iter_init(iter, h);
1030 iter->specifics.recorded.count_added_in_this_iteration_step = 0;
1032 iter->_next_fp = recorded_iter_next;
1044 static bool iter_linear_next(struct hdr_iter* iter)
1046 struct hdr_iter_linear* linear = &iter->specifics.linear;
1050 if (has_next(iter) ||
1052 iter, linear->next_value_reporting_level_lowest_equivalent))
1056 if (iter->value >= linear->next_value_reporting_level_lowest_equivalent)
1058 update_iterated_values(iter, linear->next_value_reporting_level);
1062 lowest_equivalent_value(iter->h, linear->next_value_reporting_level);
1067 if (!move_next(iter))
1072 linear->count_added_in_this_iteration_step += iter->count;
1081 void hdr_iter_linear_init(struct hdr_iter* iter, const struct hdr_histogram* h, int64_t value_units_per_bucket)
1083 hdr_iter_init(iter, h);
1085 iter->specifics.linear.count_added_in_this_iteration_step = 0;
1086 iter->specifics.linear.value_units_per_bucket = value_units_per_bucket;
1087 iter->specifics.linear.next_value_reporting_level = value_units_per_bucket;
1088 iter->specifics.linear.next_value_reporting_level_lowest_equivalent = lowest_equivalent_value(h, value_units_per_bucket);
1090 iter->_next_fp = iter_linear_next;
1101 static bool log_iter_next(struct hdr_iter *iter)
1103 struct hdr_iter_log* logarithmic = &iter->specifics.log;
1107 if (has_next(iter) ||
1109 iter, logarithmic->next_value_reporting_level_lowest_equivalent))
1113 if (iter->value >= logarithmic->next_value_reporting_level_lowest_equivalent)
1115 update_iterated_values(iter, logarithmic->next_value_reporting_level);
1118 logarithmic->next_value_reporting_level_lowest_equivalent = lowest_equivalent_value(iter->h, logarithmic->next_value_reporting_level);
1123 if (!move_next(iter))
1128 logarithmic->count_added_in_this_iteration_step += iter->count;
1137 struct hdr_iter* iter,
1142 hdr_iter_init(iter, h);
1143 iter->specifics.log.count_added_in_this_iteration_step = 0;
1144 iter->specifics.log.log_base = log_base;
1145 iter->specifics.log.next_value_reporting_level = value_units_first_bucket;
1146 iter->specifics.log.next_value_reporting_level_lowest_equivalent = lowest_equivalent_value(h, value_units_first_bucket);
1148 iter->_next_fp = log_iter_next;
1177 struct hdr_iter iter;
1183 hdr_iter_percentile_init(&iter, h, ticks_per_half_distance);
1193 percentiles = &iter.specifics.percentiles;
1194 while (hdr_iter_next(&iter))
1196 double value = iter.highest_equivalent_value / value_scale;
1198 int64_t total_count = iter.cumulative_count;