Golang runtime/pprof.Lookup(), NewProfile() functions and WriteTo() method example
package runtime/pprof
Golang runtime/pprof.Lookup(), NewProfile() functions and WriteTo() method usage example
package main
import (
"bytes"
"fmt"
"runtime/pprof"
)
func main() {
newp := pprof.NewProfile("test")
fmt.Println(newp)
p := pprof.Lookup(newp.Name())
var buf bytes.Buffer
if p == nil {
fmt.Println("Unknown profile")
} else {
p.WriteTo(&buf, 1)
fmt.Println(p)
fmt.Println(buf.String())
}
}
References :
http://golang.org/pkg/runtime/pprof/#Lookup
http://golang.org/pkg/runtime/pprof/#NewProfile
Advertisement
Something interesting
Tutorials
+24k Golang : Find biggest/largest number in array
+4.9k Python : Find out the variable type and determine the type with simple test
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+11.2k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+5k Golang : micron to centimeter example
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+19.2k Golang : Check if directory exist and create if does not exist
+8.1k Golang : Tell color name with OpenCV example
+5.5k Golang : Display advertisement images or strings on random order
+6.1k Java : Human readable password generator
+4.3k Javascript : How to show different content with noscript?