func generateLatencyDistribution(histogram, unHistogram *hdrhistogram.Histogram, requestRate uint64, percentiles Percentiles, file string) error { if percentiles == nil { percentiles = Logarithmic } f, err := os.Create(file) if err != nil { return err } defer f.Close() f.WriteString("Value Percentile TotalCount 1/(1-Percentile)\n\n") for _, percentile := range percentiles { value := float64(histogram.ValueAtQuantile(percentile)) / 1000000 _, err := f.WriteString(fmt.Sprintf("%f %f %d %f\n", value, percentile/100, 0, 1/(1-(percentile/100)))) if err != nil { return err } } // Generate uncorrected distribution. if requestRate > 0 { f, err := os.Create("uncorrected_" + file) if err != nil { return err } defer f.Close() f.WriteString("Value Percentile TotalCount 1/(1-Percentile)\n\n") for _, percentile := range percentiles { value := float64(unHistogram.ValueAtQuantile(percentile)) / 1000000 _, err := f.WriteString(fmt.Sprintf("%f %f %d %f\n", value, percentile/100, 0, 1/(1-(percentile/100)))) if err != nil { return err } } } return nil }
func cloneHistogram(in *hdrhistogram.Histogram) *hdrhistogram.Histogram { return hdrhistogram.Import(in.Export()) }
func record(h *hdrhistogram.Histogram, i int) { if err := h.RecordValue(int64(i)); err != nil { panic(err) } }
func (self *HdrHistogramLogWriter) OutputHistogram(h *hdrhistogram.Histogram) error { return binary.Write(self.w, binary.LittleEndian, h.Export()) }