From 2e613d2ded2c465bd06bd3cac30ffb4576bf72cc Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Thu, 23 Apr 2020 13:04:52 +0700 Subject: [Support] Get process statistics in ExecuteAndWait and Wait The functions sys::ExcecuteAndWait and sys::Wait now have additional argument of type pointer to structure, which is filled with process execution statistics upon process termination. These are total and user execution times and peak memory consumption. By default this argument is nullptr so existing users of these function must not change behavior. Differential Revision: https://reviews.llvm.org/D78901 --- llvm/lib/Support/Program.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Support/Program.cpp') diff --git a/llvm/lib/Support/Program.cpp b/llvm/lib/Support/Program.cpp index 0a9363c..d90cb45 100644 --- a/llvm/lib/Support/Program.cpp +++ b/llvm/lib/Support/Program.cpp @@ -31,14 +31,16 @@ int sys::ExecuteAndWait(StringRef Program, ArrayRef Args, Optional> Env, ArrayRef> Redirects, unsigned SecondsToWait, unsigned MemoryLimit, - std::string *ErrMsg, bool *ExecutionFailed) { + std::string *ErrMsg, bool *ExecutionFailed, + Optional *ProcStat) { assert(Redirects.empty() || Redirects.size() == 3); ProcessInfo PI; if (Execute(PI, Program, Args, Env, Redirects, MemoryLimit, ErrMsg)) { if (ExecutionFailed) *ExecutionFailed = false; - ProcessInfo Result = Wait( - PI, SecondsToWait, /*WaitUntilTerminates=*/SecondsToWait == 0, ErrMsg); + ProcessInfo Result = + Wait(PI, SecondsToWait, /*WaitUntilTerminates=*/SecondsToWait == 0, + ErrMsg, ProcStat); return Result.ReturnCode; } -- cgit v1.1