mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 16:24:37 +03:00
add flag to mox to store execution trace, similar to cpu/memory profiling
useful for performance testing
This commit is contained in:
12
profile.go
12
profile.go
@ -5,6 +5,7 @@ import (
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"runtime/trace"
|
||||
)
|
||||
|
||||
func memprofile(mempath string) {
|
||||
@ -43,3 +44,14 @@ func profile(cpupath, mempath string) func() {
|
||||
memprofile(mempath)
|
||||
}
|
||||
}
|
||||
|
||||
func traceExecution(path string) func() {
|
||||
f, err := os.Create(path)
|
||||
xcheckf(err, "create trace file")
|
||||
trace.Start(f)
|
||||
return func() {
|
||||
trace.Stop()
|
||||
err := f.Close()
|
||||
xcheckf(err, "close trace file")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user