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