trace profiling added

This commit is contained in:
z7zmey 2018-07-11 17:01:31 +03:00
parent 18d6d59292
commit f32a4b24c9
3 changed files with 5 additions and 2 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ php-parser
cpu.pprof cpu.pprof
mem.pprof mem.pprof
trace.out

View File

@ -55,7 +55,7 @@ php-parser [flags] <path> ...
| -d |string| dump format: [custom, go, json, pretty-json] | | -d |string| dump format: [custom, go, json, pretty-json] |
| -p | bool | show positions | | -p | bool | show positions |
| -r | bool | resolve names | | -r | bool | resolve names |
| -prof |string| start profiler: [cpu, mem] | | -prof |string| start profiler: [cpu, mem, trace] |
| -meta | bool | show meta info | | -meta | bool | show meta info |
| -php5 | bool | parse as PHP5 | | -php5 | bool | parse as PHP5 |

View File

@ -29,7 +29,7 @@ func main() {
withMeta = flag.Bool("meta", false, "show meta") withMeta = flag.Bool("meta", false, "show meta")
showResolvedNs = flag.Bool("r", false, "resolve names") showResolvedNs = flag.Bool("r", false, "resolve names")
flag.StringVar(&dumpType, "d", "", "dump format: [custom, go, json, pretty_json]") flag.StringVar(&dumpType, "d", "", "dump format: [custom, go, json, pretty_json]")
flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem]") flag.StringVar(&profiler, "prof", "", "start profiler: [cpu, mem, trace]")
flag.Parse() flag.Parse()
@ -38,6 +38,8 @@ func main() {
defer profile.Start(profile.ProfilePath("."), profile.NoShutdownHook).Stop() defer profile.Start(profile.ProfilePath("."), profile.NoShutdownHook).Stop()
case "mem": case "mem":
defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop() defer profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
case "trace":
defer profile.Start(profile.TraceProfile, profile.ProfilePath("."), profile.NoShutdownHook).Stop()
} }
pathCh := make(chan string) pathCh := make(chan string)