-
Notifications
You must be signed in to change notification settings - Fork 15
/
doc.go
60 lines (39 loc) · 2.23 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Package profiler contains tools to help profile a running Go service.
Enabling Memory Profiling
-------------------------
To enable memory profiling, modify your main method like this:
import (
"net/http"
"github.com/fogcreek/profiler"
)
func main() {
// listen on port 6060 (pick a port)
http.ListenAndServe(6060, nil)
// add handlers to help us track memory usage - they don't track memory until they're told to
profiler.AddMemoryProfilingHandlers()
}
Using Memory Profiling
----------------------
Enabling Memory Profiling exposes the following endpoints:
- http://localhost:6060/profiler/memstats: Main page you should visit
- http://localhost:6060/profiler/stop: Stop recording memory statistics
- http://localhost:6060/profiler/start: Start recording memory statistics
Working With the Template Files
-------------------------------
We bundle the template files in the Go binary with the 'go-bindata' tool. Everything in
github.com/fogcreek/profiler/profiler-web is bundled up into github.com/fogcreek/profiler/profiler-web.go
with the command, assuming your repository is in $GOPATH/src.
Production Code Generation (Check this in):
go get github.com/jteeuwen/go-bindata/...
go install github.com/jteeuwen/go-bindata/go-bindata
go-bindata -prefix "$GOPATH/src/github.com/fogcreek/profiler/profiler-web/" -pkg "profiler" -nocompress -o "$GOPATH/src/github.com/fogcreek/profiler/profiler-web.go" "$GOPATH/src/github.com/fogcreek/profiler/profiler-web"
If you'd like to make changes to the templates, then use 'go-bindata' in debug mode. Instead of compiling
the contents of the template files into profiler-web.go, it generates code to read the content of the template
files as they exist at that moment. This way, you can start your service, view the page, make changes, then
refresh the browser to see them:
Development Code Generation:
go-bindata -debug -prefix "$GOPATH/src/github.com/fogcreek/profiler/profiler-web/" -pkg "profiler" -nocompress -o "$GOPATH/src/github.com/fogcreek/profiler/profiler-web.go" "$GOPATH/src/github.com/fogcreek/profiler/profiler-web"
When you've wrapped up development, make sure to rebuild profiler-web.go to contain the contents of the file with the first non-debug command.
*/
package profiler