perf

package
v0.0.0-...-b6c5e5e Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TargetThisGoroutine monitors the calling goroutine. This will call
	// [runtime.LockOSThread] on Open and [runtime.UnlockOSThread] on Close.
	TargetThisGoroutine = targetThisGoroutine{}
)

Functions

This section is empty.

Types

type Count

type Count struct {
	RawValue uint64 // The number of events while this counter was running.

	TimeEnabled uint64 // Total time the Counter was started.
	TimeRunning uint64 // Total time the Counter was actually counting.
	// contains filtered or unexported fields
}

Count is the value of a Counter.

func (Count) Value

func (c Count) Value() (float64, string)

Value returns the measured value of Count, scaled to account for time the counter was scheduled, and to account for any conversion factors in the underlying event.

type Counter

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

A Counter reports the number of times a events.Event or group of Events occurred.

func OpenCounter

func OpenCounter(target Target, evs ...events.Event) (*Counter, error)

OpenCounter returns a new Counter that reads values for the given events.Event or group of Events on the given Target. Callers are expected to call Counter.Close when done with this Counter.

If multiple events are given, they are opened as a group, which means they will all be scheduled onto the hardware at the same time.

The counter is initially not running. Call Counter.Start to start it.

func (*Counter) Close

func (c *Counter) Close()

Close closes this counter and unlocks the goroutine from the OS thread.

func (*Counter) ReadGroup

func (c *Counter) ReadGroup(cs []Count) error

ReadGroup returns the current value of all events in c.

func (*Counter) ReadOne

func (c *Counter) ReadOne() (Count, error)

ReadOne returns the current value of the first event in c. For counters that only have a single Event, this is faster and more ergonomic than Counter.ReadGroup.

func (*Counter) Start

func (c *Counter) Start()

Start the counter.

func (*Counter) Stop

func (c *Counter) Stop()

Stop the counter.

type Target

type Target interface {
	// contains filtered or unexported methods
}

Target specifies what goroutine, thread, or CPU a Counter should monitor.

Jump to

Keyboard shortcuts

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