github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/traceviewer/histogram.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package traceviewer 6 7 import ( 8 "github.com/shogo82148/std/html/template" 9 "github.com/shogo82148/std/time" 10 ) 11 12 // TimeHistogram is an high-dynamic-range histogram for durations. 13 type TimeHistogram struct { 14 Count int 15 Buckets []int 16 MinBucket, MaxBucket int 17 } 18 19 // Add adds a single sample to the histogram. 20 func (h *TimeHistogram) Add(d time.Duration) 21 22 // BucketMin returns the minimum duration value for a provided bucket. 23 func (h *TimeHistogram) BucketMin(bucket int) time.Duration 24 25 // ToHTML renders the histogram as HTML. 26 func (h *TimeHistogram) ToHTML(urlmaker func(min, max time.Duration) string) template.HTML