minio/vendor/github.com/pkg/profile
2016-05-18 09:22:06 -07:00
..
AUTHORS server: Enable server profiling as needed. (#1565) 2016-05-09 16:18:56 -07:00
LICENSE server: Enable server profiling as needed. (#1565) 2016-05-09 16:18:56 -07:00
profile.go vendor changes to pkg/profile (#1671) 2016-05-18 09:22:06 -07:00
README.md server: Enable server profiling as needed. (#1565) 2016-05-09 16:18:56 -07:00
wercker.yml server: Enable server profiling as needed. (#1565) 2016-05-09 16:18:56 -07:00

profile

Simple profiling support package for Go

installation

go get github.com/pkg/profile

usage

Enabling profiling in your application is as simple as one line at the top of your main function

import "github.com/pkg/profile"

func main() {
    defer profile.Start().Stop()
    ...
}

options

What to profile is controlled by config value passed to profile.Start. By default CPU profiling is enabled.

import "github.com/pkg/profile"

func main() {
    // p.Stop() must be called before the program exits to
    // ensure profiling information is written to disk.
    p := profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook)
    ...
}

Several convenience package level values are provided for cpu, memory, and block (contention) profiling.

For more complex options, consult the documentation.