add flag to mox to store execution trace, similar to cpu/memory profiling

useful for performance testing
This commit is contained in:
Mechiel Lukkien
2023-09-12 14:43:52 +02:00
parent 4a4ccb83a3
commit 6f1e38f2ce
2 changed files with 17 additions and 1 deletions

View File

@ -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")
}
}