reporter

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reporter

type Reporter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Reporter can be used to output timing information on how long something is taking.

func New

func New(operation string, logger log15.Logger) *Reporter

New returns a reporter that will log how long operation took to logger.

func (*Reporter) Enable

func (r *Reporter) Enable()

Enable will cause future TimeOperation() calls to to time the operation. This is so that if not enabled, you can have TimeOperation() calls throughout your code and it won't be expensive since they will do nothing until you chose to Enable() the reporter. NB: this is NOT thread safe.

func (*Reporter) Report

func (r *Reporter) Report()

Report outputs timings collected since the last Report() call. Operations that returned an error are not included in these reports.

func (*Reporter) ReportFinal

func (r *Reporter) ReportFinal()

ReportFinal reports overall and failed timings.

func (*Reporter) StartReporting

func (r *Reporter) StartReporting(frequency time.Duration)

StartReporting calls Enable() and then Report() regularly every frequency. NB: this is NOT thread safe.

func (*Reporter) StopReporting

func (r *Reporter) StopReporting()

StopReporting stops the regular calling of Report() and triggers ReportFinal().

func (*Reporter) TimeOperation

func (r *Reporter) TimeOperation(f func() error) error

TimeOperation, if Enable() has not yet been called, will simply call your given func and return its error. If Enable() has been called, it will time how long your func takes to run, so that Report() can report details about your func.

Jump to

Keyboard shortcuts

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