From 92e8a5a0ead6142d9a23143ebece8748491bbac2 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 20 Dec 2004 21:44:27 +0000 Subject: [PATCH] Fix a bug where system time always equals user time llvm-svn: 19075 --- llvm/lib/Support/Timer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 1b2f91d03b43..47d696804a77 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -105,12 +105,19 @@ static TimeRecord getTimeRecord(bool Start) { sys::TimeValue user(0,0); sys::TimeValue sys(0,0); - sys::Process::GetTimeUsage(now,user,sys); + long MemUsed = 0; + if (Start) { + sys::Process::GetTimeUsage(now,user,sys); + MemUsed = sys::Process::GetMallocUsage(); + } else { + MemUsed = sys::Process::GetMallocUsage(); + sys::Process::GetTimeUsage(now,user,sys); + } - Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; - Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; - Result.UserTime = sys.seconds() + sys.microseconds() / 1000000.0; - Result.MemUsed = sys::Process::GetMallocUsage(); + Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; + Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; + Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; + Result.MemUsed = MemUsed; return Result; }