stopwatch

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stopwatch is used to time things. Create a stopwatch with Start, then on success record the timing with Finish.

It's recommended you do not record errors, since they can have vastly different timings (maybe we add an Error method in the future and record a different event).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FinishOpts

type FinishOpts struct {
	Logger       *slog.Logger
	Key          string
	ElapsedKey   string
	Milliseconds bool
	Level        slog.Level
}

type LapOpts

type LapOpts FinishOpts

type StartOpts

type StartOpts struct {
	Key   string
	Level slog.Level
}

type Stopwatch

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

func Start

func Start(ctx context.Context, logger *slog.Logger, operation string) *Stopwatch

func StartWith

func StartWith(ctx context.Context, logger *slog.Logger, operation string, opts StartOpts) *Stopwatch

func (*Stopwatch) Finish

func (sw *Stopwatch) Finish(ctx context.Context)

func (*Stopwatch) FinishWith

func (sw *Stopwatch) FinishWith(ctx context.Context, opts FinishOpts)

func (*Stopwatch) Lap

func (sw *Stopwatch) Lap(ctx context.Context)

func (*Stopwatch) LapWith

func (sw *Stopwatch) LapWith(ctx context.Context, opts LapOpts)

Jump to

Keyboard shortcuts

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