probe

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Average

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

func NewAverage

func NewAverage(duration time.Duration, maxtimes ...time.Duration) *Average

func (*Average) Hit

func (a *Average) Hit()

func (*Average) Reset

func (a *Average) Reset()

func (*Average) Start

func (a *Average) Start()

func (*Average) Value

func (a *Average) Value() []float64

type Counter

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

Counter represents a thread-safe counter. This structure provides a simple counter that can be safely incremented or decremented in a concurrent environment using atomic operations.

func NewCounter

func NewCounter() *Counter

NewCounter initializes and returns a new instance of Counter. This function creates a Counter instance with the initial count set to zero.

Returns: - *Counter: A pointer to the newly created Counter instance.

func (*Counter) Decrement

func (c *Counter) Decrement() uint64

Decrement safely decrements the counter by one. This method uses atomic operations to ensure that the decrement operation is thread-safe,

func (*Counter) Increment

func (c *Counter) Increment() uint64

Increment safely increments the counter by one. This method uses atomic operations to ensure that the increment operation is thread-safe, preventing race conditions in a concurrent environment.

func (*Counter) Reset

func (c *Counter) Reset()

func (*Counter) Value

func (c *Counter) Value() uint64

Value returns the current value of the counter.

This method uses atomic operations to ensure that the read operation is thread-safe. It returns the current value of the counter without modifying it.

Returns: - uint64: The current value of the counter.

type Duration

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

Duration measures the elapsed time from a starting point. This structure allows for the recording of elapsed time in a thread-safe manner using atomic operations for the start time.

func NewDuration

func NewDuration() *Duration

NewDuration initializes and returns a new instance of Duration. It sets the start time to the current time at the moment of creation.

Returns: - *Duration: A pointer to the newly created Duration instance.

func (*Duration) Elapsed

func (pd *Duration) Elapsed() time.Duration

Elapsed returns the elapsed time since start. The method calculates the time elapsed since the start time, which is stored as Unix nanoseconds, and returns the duration in time.Duration format.

Returns: - time.Duration: The elapsed time since start as a time.Duration.

func (*Duration) Start

func (pd *Duration) Start()

Start sets or resets the start time of the duration measurement. This method updates the start time to the current time using atomic operations to ensure thread safety.

Jump to

Keyboard shortcuts

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