profile

package
v0.0.0-...-dddda54 Latest Latest
Warning

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

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

Documentation

Overview

profiling of your Go application.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CPUProfile is the name of cpu profile which controls if cpu profiling will be enabled.
	// It defaults to false.
	CPUProfile string

	// MemProfile is the name of memory profile which controls if cpu profiling will be enabled.
	// It defaults to false.
	MemProfile string

	// MemProfile is the name of memory profile which controls if cpu profiling will be enabled.
	// It defaults to false.
	BlockProfile string

	// NoShutdownHook controls whether the profiling package should
	// hook SIGINT to write profiles cleanly.
	// Programs with more sophisticated signal handling should set
	// this to true and ensure the Stop() function returned from Start()
	// is called during shutdown.
	NoShutdownHook bool
	// contains filtered or unexported fields
}

Config controls the operation of the profile package.

func (*Config) Start

func (cfg *Config) Start() error

Start starts a new profiling session configured using *Config. The caller should call the Stop method to cleanly stop profiling.

Example
p := &Config{CPUProfile: "test"}
if err := p.Start(); err != nil {
	// error handle
	return
}
Output:

func (*Config) Stop

func (cfg *Config) Stop()

Stop stops all profile.

Example
p := &Config{CPUProfile: "cpu.prof", NoShutdownHook: true}
if err := p.Start(); err != nil {
	// error handle
	return
}
p.Stop()
Output:

type Timer

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

Timer recoreds time cost.

func NewTimer

func NewTimer() *Timer

NewTimer creates a new timer and start it.

func (*Timer) Elapsed

func (t *Timer) Elapsed() time.Duration

Elapsed returns the time duration from the time of start or last elapsed.

func (*Timer) TotalCost

func (t *Timer) TotalCost() time.Duration

TotalCost will stop the timer and return the total cost time.

Jump to

Keyboard shortcuts

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