From 1be1a06281dccada078a2a51e8b483811af8f596 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 29 Mar 2024 15:02:10 +0100 Subject: 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. --- pkg/ipc/ipc.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'pkg/ipc') 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() -- cgit mrf-deployment