aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ipc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-03-29 15:02:10 +0100
committerDmitry Vyukov <dvyukov@google.com>2024-04-09 07:55:50 +0000
commit1be1a06281dccada078a2a51e8b483811af8f596 (patch)
tree6340df1c2d1704f1784ba63164d3088b7c91ef61 /pkg/ipc
parent73f4b622a34ffc998a542f5e109fb05a1d892272 (diff)
all: refactor stats
Add ability for each package to create and export own stats. Each stat is self-contained, describes how it should be presented, and there is not need to copy them from one package to another. Stats also keep historical data and allow building graphs over time.
Diffstat (limited to 'pkg/ipc')
-rw-r--r--pkg/ipc/ipc.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go
index c90e56caf..f0aeb2b41 100644
--- a/pkg/ipc/ipc.go
+++ b/pkg/ipc/ipc.go
@@ -95,8 +95,9 @@ type CallInfo struct {
}
type ProgInfo struct {
- Calls []CallInfo
- Extra CallInfo // stores Signal and Cover collected from background threads
+ Calls []CallInfo
+ Extra CallInfo // stores Signal and Cover collected from background threads
+ Elapsed time.Duration // total execution time of the program
}
type Env struct {
@@ -275,7 +276,9 @@ func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info *ProgInf
return
}
+ start := osutil.MonotonicNano()
output, hanged, err0 = env.cmd.exec(opts, progData)
+ elapsed := osutil.MonotonicNano() - start
if err0 != nil {
env.cmd.close()
env.cmd = nil
@@ -283,8 +286,11 @@ func (env *Env) Exec(opts *ExecOpts, p *prog.Prog) (output []byte, info *ProgInf
}
info, err0 = env.parseOutput(p, opts)
- if info != nil && env.config.Flags&FlagSignal == 0 {
- addFallbackSignal(p, info)
+ if info != nil {
+ info.Elapsed = elapsed
+ if env.config.Flags&FlagSignal == 0 {
+ addFallbackSignal(p, info)
+ }
}
if !env.config.UseForkServer {
env.cmd.close()