« Back to Search  |  Reader Mode  |  Switch to Full Retro Site View Links: Stay in Reader  |  Retro Mode: ON  |  Original »
GitHub · Extracted in 1038 ms

GitHub - pkg/profile: Simple profiling for Go

Source: https://github.com/pkg/profile

Repository navigation

profile
Public

About

Simple profiling for Go

Resources

Readme BSD-2-Clause license Activity Custom properties

Stars

2.1k stars

Watchers

35 watching

Forks

121 forks Report repository
Branches

Tags
Go to Branches page Go to Tags page

Latest commit

 

History


129 Commits
View commit history for this file.

Folders and files

Name Name Last commit message Last commit date
.travis.yml .travis.yml    
AUTHORS AUTHORS    
LICENSE LICENSE    
README.md README.md    
example_test.go example_test.go    
go.mod go.mod    
profile.go profile.go    
profile_test.go profile_test.go    
trace_test.go trace_test.go    

Repository files navigation

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)
    ...
    // You can enable different kinds of memory profiling, either Heap or Allocs where Heap
    // profiling is the default with profile.MemProfile.
    p := profile.Start(profile.MemProfileAllocs, 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 .

contributing

We welcome pull requests, bug fixes and issue reports.

Before proposing a change, please discuss it first by raising an issue.

About

Simple profiling for Go

Resources

Readme BSD-2-Clause license Activity Custom properties

Stars

2.1k stars

Watchers

35 watching

Forks

121 forks Report repository

Releases

Packages

Used by

Contributors

Languages