diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-04-30 16:02:57 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-04-30 17:18:29 +0200 |
| commit | 136082ab38d86932bc3ed0087694e99d0e55491b (patch) | |
| tree | e4b44339320e39f60df4ecd7170666602191b583 /sys/syz-sysgen | |
| parent | cc90e4763e4f1932275adf9c7bd5a1176cecdc74 (diff) | |
pkg/cmdprof: add package
cmdprof simplifies cpu/memory profiling for command line tools. Use as:
flag.Parse()
defer cmdprof.Install
Diffstat (limited to 'sys/syz-sysgen')
| -rw-r--r-- | sys/syz-sysgen/sysgen.go | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index a424e1488..1197a8cce 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -13,14 +13,13 @@ import ( "os" "path/filepath" "reflect" - "runtime" - "runtime/pprof" "sort" "strings" "sync" "text/template" "github.com/google/syzkaller/pkg/ast" + "github.com/google/syzkaller/pkg/cmdprof" "github.com/google/syzkaller/pkg/compiler" "github.com/google/syzkaller/pkg/hash" "github.com/google/syzkaller/pkg/osutil" @@ -29,10 +28,6 @@ import ( "github.com/google/syzkaller/sys/targets" ) -var ( - flagMemProfile = flag.String("memprofile", "", "write a memory profile to the file") -) - type SyscallData struct { Name string CallName string @@ -64,6 +59,7 @@ type ExecutorData struct { func main() { flag.Parse() + defer cmdprof.Install()() var OSList []string for OS := range targets.List { @@ -175,18 +171,6 @@ func main() { } writeExecutorSyscalls(data) - - if *flagMemProfile != "" { - f, err := os.Create(*flagMemProfile) - if err != nil { - failf("could not create memory profile: ", err) - } - runtime.GC() // get up-to-date statistics - if err := pprof.WriteHeapProfile(f); err != nil { - failf("could not write memory profile: ", err) - } - f.Close() - } } func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint64, out io.Writer) { |
