proc

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

* @Author: cnzf1 * @Date: 2022-12-02 21:02:42 * @LastEditors: cnzf1 * @LastEditTime: 2023-01-11 11:08:51 * @Description:

Index

Constants

View Source
const DefaultMemProfileRate = 4096

DefaultMemProfileRate is the default memory profiling rate. See also http://golang.org/pkg/runtime/#pkg-variables

Variables

This section is empty.

Functions

This section is empty.

Types

type Profile

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

Profile represents an active profiling session.

func (*Profile) Stop

func (p *Profile) Stop()

Stop stops the profile and flushes any unwritten data.

type Stopper

type Stopper interface {
	Stop()
}

Stopper interface wraps the method Stop.

func StartProfile

func StartProfile(dumpDir ...string) Stopper

StartProfile starts a new profiling session. The caller should call the Stop method on the value returned to cleanly stop profiling.

go func() {
	var profiler proc.Stopper
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGTERM)
	for {
		v := <-signals
		switch v {
		case syscall.SIGUSR2:
			if profiler == nil {
				profiler = proc.StartProfile()
			} else {
				profiler.Stop()
				profiler = nil
			}
		}
	}
}()

Jump to

Keyboard shortcuts

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