prof

package module
v0.0.0-...-856954a Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 11 Imported by: 4

README

go-cpu-mem-profiler

a hopefully simple to use cpu and mem profiler for GOlang

import (
	"github.com/go-while/go-cpu-mem-profiler"
)

var (
	Prof *prof.Profiler
)

func main() {
	Prof = prof.NewProf()

	// start a webserver
	go Prof.PprofWeb(":1234")

	// start a cpu profiler
	// _ is 'CPUfile' = the open file handle
	_, err := Prof.StartCPUProfile()
	if err != nil {
		os.Exit(1)
	}

	// stops the running cpu profiler
	Prof.StopCPUProfile()

	// starts a memory profiler for runtime
	// use waittime to delay the start
	Prof.StartMemProfile(runtime, waittime)
}

Contributing

Contributions to this code are welcome.

If you have suggestions for improvements or find issues, please feel free to open an issue or submit a pull request.

License

This code is provided under the MIT License. See the LICENSE file for details.

GitHub Profile Trophy

🏆 Add dynamically generated GitHub Stat Trophies on your readme

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Profiler

type Profiler struct {
	CPUProfile     bool // set before boot
	MEMProfile     bool // set before boot
	CpuProfileFile *os.File
	MemProfileFile *os.File
	// contains filtered or unexported fields

} // end Profiler struct

func NewProf

func NewProf() *Profiler

func (*Profiler) CatchInterruptSignal

func (p *Profiler) CatchInterruptSignal(cpu bool, mem bool)

func (*Profiler) PprofWeb

func (p *Profiler) PprofWeb(addr string)

func (*Profiler) StartCPUProfile

func (p *Profiler) StartCPUProfile() (*os.File, error)

func (*Profiler) StartMemProfile

func (p *Profiler) StartMemProfile(duration time.Duration, wait time.Duration) error

func (*Profiler) StopCPUProfile

func (p *Profiler) StopCPUProfile()

Jump to

Keyboard shortcuts

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