~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/net/http/pprof/pprof.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
// To use pprof, link this package into your program:
15
15
//      import _ "net/http/pprof"
16
16
//
 
17
// If your application is not already running an http server, you
 
18
// need to start one.  Add "net/http" and "log" to your imports and
 
19
// the following code to your main function:
 
20
//
 
21
//      go func() {
 
22
//              log.Println(http.ListenAndServe("localhost:6060", nil))
 
23
//      }()
 
24
//
17
25
// Then use the pprof tool to look at the heap profile:
18
26
//
19
27
//      go tool pprof http://localhost:6060/debug/pprof/heap
22
30
//
23
31
//      go tool pprof http://localhost:6060/debug/pprof/profile
24
32
//
25
 
// Or to view all available profiles:
26
 
//
27
 
//      go tool pprof http://localhost:6060/debug/pprof/
 
33
// Or to look at the goroutine blocking profile:
 
34
//
 
35
//      go tool pprof http://localhost:6060/debug/pprof/block
 
36
//
 
37
// To view all available profiles, open http://localhost:6060/debug/pprof/
 
38
// in your browser.
28
39
//
29
40
// For a study of the facility in action, visit
30
41
//
161
172
// listing the available profiles.
162
173
func Index(w http.ResponseWriter, r *http.Request) {
163
174
        if strings.HasPrefix(r.URL.Path, "/debug/pprof/") {
164
 
                name := r.URL.Path[len("/debug/pprof/"):]
 
175
                name := strings.TrimPrefix(r.URL.Path, "/debug/pprof/")
165
176
                if name != "" {
166
177
                        handler(name).ServeHTTP(w, r)
167
178
                        return