]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Start a simpler replacement for davecheney's profile package
authorMatt Joiner <anacrolix@gmail.com>
Wed, 9 Jul 2014 14:14:19 +0000 (00:14 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 9 Jul 2014 14:14:19 +0000 (00:14 +1000)
util/profile/profile.go [new file with mode: 0644]

diff --git a/util/profile/profile.go b/util/profile/profile.go
new file mode 100644 (file)
index 0000000..74bfae6
--- /dev/null
@@ -0,0 +1,19 @@
+package profile
+
+import (
+       "log"
+       "net/http"
+       _ "net/http/pprof"
+       "os"
+)
+
+func init() {
+       if httpAddr := os.Getenv("GOPROF"); httpAddr != "" {
+               go func() {
+                       err := http.ListenAndServe(httpAddr, nil)
+                       if err != nil {
+                               log.Print(err)
+                       }
+               }()
+       }
+}