add cpuprofile
This commit is contained in:
parent
08f9332704
commit
86e41350b3
@ -9,6 +9,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
|
"runtime/pprof"
|
||||||
"flag"
|
"flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -197,8 +198,19 @@ func main() {
|
|||||||
input := flag.String("i", "", "input file")
|
input := flag.String("i", "", "input file")
|
||||||
output := flag.String("o", "", "output file")
|
output := flag.String("o", "", "output file")
|
||||||
inputGob := flag.String("g", "", "input gob file")
|
inputGob := flag.String("g", "", "input gob file")
|
||||||
|
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *cpuprofile != "" {
|
||||||
|
f, err := os.Create(*cpuprofile)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pprof.StartCPUProfile(f)
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ts.DebugReader = true
|
ts.DebugReader = true
|
||||||
ts.DebugWriter = true
|
ts.DebugWriter = true
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user