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.
- Host: GitHub
- URL: https://github.com/knadh/profiler
- Owner: knadh
- License: mit
- Created: 2022-06-16T14:17:22.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-23T05:43:38.000Z (almost 2 years ago)
- Last Synced: 2025-03-19T00:17:59.217Z (about 1 year ago)
- Topics: pprof, profiler, profiling, profiling-library
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 32
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
}
```