From 86e41350b3be5c51da08e8c33241af67fc41d752 Mon Sep 17 00:00:00 2001 From: nareix Date: Wed, 9 Dec 2015 14:24:16 +0800 Subject: [PATCH] add cpuprofile --- example/test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/example/test.go b/example/test.go index e9d752b..24be502 100644 --- a/example/test.go +++ b/example/test.go @@ -9,6 +9,7 @@ import ( "fmt" "encoding/hex" "encoding/gob" + "runtime/pprof" "flag" ) @@ -197,8 +198,19 @@ func main() { input := flag.String("i", "", "input file") output := flag.String("o", "", "output file") inputGob := flag.String("g", "", "input gob file") + cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file") flag.Parse() + if *cpuprofile != "" { + f, err := os.Create(*cpuprofile) + if err != nil { + return + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } + + ts.DebugReader = true ts.DebugWriter = true