counters

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package counters is the generic user-defined counter API: one line in application code (isutools.Count("cache_hit")) makes cache hit/miss and similar custom events visible per benchmark generation.

Index

Constants

View Source
const (
	// DefaultMaxNames bounds dynamic counter identities per generation.
	DefaultMaxNames = 1024
	// MaxNameBytes bounds the retained memory for each identity.
	MaxNameBytes = 128
	// OverflowName receives observations outside either bound.
	OverflowName = "(other)"
)

Variables

View Source
var Default = NewRegistry()

Default is the registry the facade helpers write into.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name  string `json:"name"`
	Count int64  `json:"count"`
}

Entry is one counter value in a snapshot.

type Registry

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

Registry is a concurrency-safe named counter set.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty Registry.

func (*Registry) Add

func (r *Registry) Add(name string, delta int64)

Add increments a named counter by delta.

func (*Registry) Dropped added in v1.1.0

func (r *Registry) Dropped() uint64

Dropped returns how many observations were merged into OverflowName.

func (*Registry) Reset

func (r *Registry) Reset()

Reset clears all counters (called per generation).

func (*Registry) Snapshot

func (r *Registry) Snapshot() []Entry

Snapshot returns entries sorted by count descending (ties by name).

Jump to

Keyboard shortcuts

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