An open API service indexing awesome lists of open source software.

https://github.com/knadh/profiler

A simple wrapper over Go runtime/pprof for running multiple concurrent profiles and dumping results to files.
https://github.com/knadh/profiler

pprof profiler profiling profiling-library

Last synced: 11 months ago
JSON representation

A simple wrapper over Go runtime/pprof for running multiple concurrent profiles and dumping results to files.

Awesome Lists containing this project

README

          

# profiler

profiler is a tiny wrapper around runtime/pprof for easily profiling Go programs. It allows running one or more profiles (cpu, mem etc.) simultaneously while avoiding boilerplate. The results are dumped to files. This is a rewrite of [pkg/profile](https://github.com/pkg/profile/) with the key difference of supporting multiple concurrent profiles.

## Install
```shell
go get github.com/knadh/profiler
````

## Usage
```go
import "github.com/knadh/profiler"

func main() {
// Pass one or more modes: Block, Cpu, Goroutine, Mem, Mutex, ThreadCreate, Trace ...
p := profiler.New(profiler.Conf{}, profiler.Cpu, profiler.Mem)
p.Start()

// Stuff ...

p.Stop()
}
```

### Optional config
```go
profiler.Conf{
// Directory path to dump the profile output to. Default is current directory.
DirPath string

// Quiet disables info log output.
Quiet bool

// NoShutdownHook controls whether the profiling package should
// hook SIGINT to automatically Stop().
NoShutdownHook bool

// MemProfileRate is the rate for the memory profiler. Default is 4096.
// To include every allocated block in the profile, set MemProfileRate to 1.
MemProfileRate int

// MemProfileType = heap or alloc. Default is heap.
MemProfileType string
}
```