From d81b6d9e1d96eba1925481cba836168304951a03 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 30 May 2026 11:30:47 +0200 Subject: [PATCH] Log CPU time of external commands in addition to wall-clock time For certain kinds of performance investigations it is useful to see this, and doesn't terribly pollute the log, so just do this always. --- pkg/commands/oscommands/cmd_obj_runner.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/commands/oscommands/cmd_obj_runner.go b/pkg/commands/oscommands/cmd_obj_runner.go index ae11298ae..978682618 100644 --- a/pkg/commands/oscommands/cmd_obj_runner.go +++ b/pkg/commands/oscommands/cmd_obj_runner.go @@ -105,12 +105,18 @@ func (self *cmdObjRunner) RunWithOutputAux(cmdObj *CmdObj) (string, error) { } t := time.Now() - output, err := sanitisedCommandOutput(cmdObj.GetCmd().CombinedOutput()) + cmd := cmdObj.GetCmd() + output, err := sanitisedCommandOutput(cmd.CombinedOutput()) if err != nil { self.log.WithField("command", cmdObj.ToString()).Error(output) } - self.log.Infof("%s (%s)", cmdObj.ToString(), time.Since(t)) + wall := time.Since(t) + if ps := cmd.ProcessState; ps != nil { + self.log.Infof("%s (wall %s, cpu %s)", cmdObj.ToString(), wall, ps.UserTime()+ps.SystemTime()) + } else { + self.log.Infof("%s (wall %s)", cmdObj.ToString(), wall) + } return output, err }