stats

package
v0.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is a thread-safe view of the C++ logarithmic-histogram engine (1 µs to 60 s, ~3 significant figures in log10 binning). All methods are safe for concurrent use.

func NewEngine

func NewEngine() *Engine

NewEngine creates a new statistics engine. The caller should call Close when the engine is no longer needed to release C++ memory (finalizers are not reliable for C++ destructors).

func (*Engine) Close

func (e *Engine) Close()

Close releases native resources. Safe to call more than once.

func (*Engine) GetPercentile

func (e *Engine) GetPercentile(p float64) float64

GetPercentile returns the estimated latency in nanoseconds for the given percentile p in [0, 100] using a histogram CDF. Returns 0 if there are no samples.

func (*Engine) RecordLatency

func (e *Engine) RecordLatency(nanos int64)

RecordLatency records one latency sample in nanoseconds. Values are clamped to the configured histogram range for bucketing: below 1 µs to the first bucket, at or above 60 s to the last bucket. Negative values are treated like zero (first bucket).

func (*Engine) Reset

func (e *Engine) Reset()

Reset clears all buckets and the total count.

func (*Engine) Total

func (e *Engine) Total() uint64

Total returns the number of samples recorded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL