Documentation
¶
Overview ¶
Package p99 provides a low-cost, zero-allocation histogram for recording event durations in nanoseconds and querying performance percentiles (p50, p90, p99, p99.9, and so on).
Histogram uses 64 logarithmic power-of-two buckets and performs linear interpolation within buckets to approximate percentile values. It is designed for high-frequency latency measurement with minimal overhead.
Index ¶
- Constants
- func BucketIndex(timeInNs uint64) int
- func BucketRange(index int) (bool, uint64, uint64)
- func Version() uint64
- func VersionString() string
- type Histogram
- func (h *Histogram) BucketValue(index int) (bool, uint64)
- func (h *Histogram) Buckets() [BucketCount]uint64
- func (h *Histogram) Clear()
- func (h *Histogram) EventCount() uint64
- func (h *Histogram) EventTimeTotal() (bool, uint64)
- func (h *Histogram) EventTimeTotalRaw() uint64
- func (h *Histogram) GoString() string
- func (h *Histogram) HasOverflowed() bool
- func (h *Histogram) MaxEventTime() (bool, uint64)
- func (h *Histogram) MinEventTime() (bool, uint64)
- func (h *Histogram) PushEventDuration(d time.Duration) bool
- func (h *Histogram) PushEventTimeMs(timeInMs uint64) bool
- func (h *Histogram) PushEventTimeNs(timeInNs uint64) bool
- func (h *Histogram) PushEventTimeS(timeInS uint64) bool
- func (h *Histogram) PushEventTimeUs(timeInUs uint64) bool
- func (h *Histogram) String() string
- func (h *Histogram) ValueAtP50() (bool, uint64)
- func (h *Histogram) ValueAtP75() (bool, uint64)
- func (h *Histogram) ValueAtP90() (bool, uint64)
- func (h *Histogram) ValueAtP95() (bool, uint64)
- func (h *Histogram) ValueAtP99() (bool, uint64)
- func (h *Histogram) ValueAtP99_5() (bool, uint64)
- func (h *Histogram) ValueAtP99_9() (bool, uint64)
- func (h *Histogram) ValueAtP99_99() (bool, uint64)
- func (h *Histogram) ValueAtP99_999() (bool, uint64)
- func (h *Histogram) ValueAtP99_999_9() (bool, uint64)
- func (h *Histogram) ValueAtPercentile(percentile float64) (bool, uint64)
Constants ¶
const ( VersionMajor uint16 = 0 VersionMinor uint16 = 2 VersionPatch uint16 = 0 VersionAB uint16 = ver2go.Release )
const BucketCount = 64
Specifies the number of logarithmic buckets in a Histogram.
Variables ¶
This section is empty.
Functions ¶
func BucketIndex ¶
Calculates the bucket index for a duration in nanoseconds.
func BucketRange ¶
Attempts to obtain the inclusive nanosecond range for the given bucket index.
func Version ¶
func Version() uint64
Version returns this library's version as a packed 64-bit integer, formed by ver2go.CombineVersion from VersionMajor, VersionMinor, VersionPatch, and VersionAB. The result is suitable for numeric comparison: a later release has a strictly greater value than an earlier one that uses the same packing.
func VersionString ¶
func VersionString() string
VersionString returns this library's version as a human-readable string, formed by ver2go.CalcVersionString from VersionMajor, VersionMinor, VersionPatch, and VersionAB. For a final (non-prerelease) version the result is of the form "MAJOR.MINOR.PATCH", e.g. "0.2.0".
Types ¶
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
A low-cost, zero-allocation, fixed-size structure for recording event durations in nanoseconds and querying high-resolution percentiles.
func (*Histogram) BucketValue ¶
Attempts to obtain the count of events in the bucket at index.
func (*Histogram) Buckets ¶
func (h *Histogram) Buckets() [BucketCount]uint64
Returns a copy of all bucket counts.
func (*Histogram) Clear ¶
func (h *Histogram) Clear()
Resets the histogram to the equivalent of a newly constructed instance.
func (*Histogram) EventCount ¶
Returns the number of recorded events.
func (*Histogram) EventTimeTotal ¶
Attempts to obtain the total event time in nanoseconds when no overflow has occurred.
func (*Histogram) EventTimeTotalRaw ¶
Returns the total event time in nanoseconds regardless of whether overflow has occurred.
func (*Histogram) HasOverflowed ¶
Reports whether an overflow has occurred.
func (*Histogram) MaxEventTime ¶
Attempts to obtain the maximum event time observed.
func (*Histogram) MinEventTime ¶
Attempts to obtain the minimum event time observed.
func (*Histogram) PushEventDuration ¶
Records an event with the given duration. The nanosecond value is truncated to uint64.
func (*Histogram) PushEventTimeMs ¶
Records an event with the given number of milliseconds.
func (*Histogram) PushEventTimeNs ¶
Records an event with the given number of nanoseconds. Returns false if overflow has occurred or the running total would overflow.
func (*Histogram) PushEventTimeS ¶
Records an event with the given number of seconds.
func (*Histogram) PushEventTimeUs ¶
Records an event with the given number of microseconds.
func (*Histogram) ValueAtP50 ¶
Attempts to obtain the approximated duration at p50 (50th percentile).
func (*Histogram) ValueAtP75 ¶
Attempts to obtain the approximated duration at p75 (75th percentile).
func (*Histogram) ValueAtP90 ¶
Attempts to obtain the approximated duration at p90 (90th percentile).
func (*Histogram) ValueAtP95 ¶
Attempts to obtain the approximated duration at p95 (95th percentile).
func (*Histogram) ValueAtP99 ¶
Attempts to obtain the approximated duration at p99 (99th percentile).
func (*Histogram) ValueAtP99_5 ¶
Attempts to obtain the approximated duration at p99.5 (99.5th percentile).
func (*Histogram) ValueAtP99_9 ¶
Attempts to obtain the approximated duration at p99.9 (99.9th percentile).
func (*Histogram) ValueAtP99_99 ¶
Attempts to obtain the approximated duration at p99.99 (99.99th percentile).
func (*Histogram) ValueAtP99_999 ¶
Attempts to obtain the approximated duration at p99.999 (99.999th percentile).
func (*Histogram) ValueAtP99_999_9 ¶
Attempts to obtain the approximated duration at p99.9999 (99.9999th percentile).
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
build_histogram
command
Demonstrates recording event durations and querying percentiles.
|
Demonstrates recording event durations and querying percentiles. |
|
libver
command
|
|
|
version
command
|