Update changes the Min and Max fields if value is less than or greater than the current values.
(value int64)
| 719 | |
| 720 | // Update changes the Min and Max fields if value is less than or greater than the current values. |
| 721 | func (histogram *HistogramData) Update(value int64) { |
| 722 | if value > histogram.Max { |
| 723 | histogram.Max = value |
| 724 | } |
| 725 | if value < histogram.Min { |
| 726 | histogram.Min = value |
| 727 | } |
| 728 | |
| 729 | histogram.Sum += value |
| 730 | histogram.Count++ |
| 731 | |
| 732 | for index := 0; index <= len(histogram.Bounds); index++ { |
| 733 | // Allocate value in the last buckets if we reached the end of the Bounds array. |
| 734 | if index == len(histogram.Bounds) { |
| 735 | histogram.CountPerBucket[index]++ |
| 736 | break |
| 737 | } |
| 738 | |
| 739 | if value < int64(histogram.Bounds[index]) { |
| 740 | histogram.CountPerBucket[index]++ |
| 741 | break |
| 742 | } |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | // PrintHistogram prints the histogram data in a human-readable format. |
| 747 | func (histogram *HistogramData) PrintHistogram() { |
no outgoing calls
no test coverage detected