Coder Social home page Coder Social logo

wstrmr / profile Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fcgmedia/profile

0.0 2.0 0.0 185 KB

A simple profiling support package for Go

Home Page: http://dave.cheney.net/2013/07/07/introducing-profile-super-simple-profiling-for-go-programs

License: BSD 2-Clause "Simplified" License

Go 100.00%

profile's Introduction

profile

Simple profiling support package for Go

installation

go get github.com/davecheney/profile

usage

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

import "github.com/davecheney/profile"

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

options

What to profile is controlled by the *profile.Config value passed to profile.Start. A nil Config is the same as choosing all the defaults. By default no profiles are enabled.

import "github.com/davecheney/profile"

func main() {
    cfg := profile.Config{
        MemProfile:     true,
        ProfilePath:    ".",  // store profiles in current directory
        NoShutdownHook: true, // do not hook SIGINT
    }

    // p.Stop() must be called before the program exits to
    // ensure profiling information is written to disk.
    p := profile.Start(&cfg)
    ...
}

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

For more complex options, consult the documentation on the profile.Config type. Enabling more than one profile at once may cause your results to be less reliable as profiling itself is not without overhead.

profile's People

Contributors

davecheney avatar aleksi avatar dgryski avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.