counters

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 2 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

This section is empty.

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) 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