timer

package
v0.0.0-...-0939e29 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Reports averages and histograms. These metrics will show up at /debug/metrics as timer_* histograms There is a separate /debug/timers page for an overview of these metrics only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Console

func Console(name string) func()

Useful for debugging, prints running times to the console. When called with defer use (note the trailing "()"): defer timer.Console("name")()

func DebugConsole

func DebugConsole(name string) func()

func MilliCounter

func MilliCounter() milliCounter

func ServeHTTP

func ServeHTTP(resp http.ResponseWriter, req *http.Request)

Writes timing reports as json

Types

type Timer

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

Use NewTimer for construction

func NewTimer

func NewTimer(name string) (ret Timer)

func (*Timer) Batch

func (t *Timer) Batch(batchSize int) func()

Usage, note the final (): defer t.Batch(10)()

Note: this adds just one value for the full batch. Implications:

  • the count at the summary page has to be multiplied with the average batch size to get the true count.
  • If batch sizes are different than this overrepresent small batches.

func (*Timer) One

func (t *Timer) One() func()

Usage, note the final (): defer t.One()()

func (*Timer) Print

func (t *Timer) Print(w io.Writer)

func (*Timer) String

func (t *Timer) String() string

Jump to

Keyboard shortcuts

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