summaryrefslogtreecommitdiffstats
path: root/lib/Support/Timer.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-23 18:12:30 +0000
committerOwen Anderson <resistor@mac.com>2009-06-23 18:12:30 +0000
commitcd92c1000eeceb195daaab47ca4a2161ab2da410 (patch)
treea6434844d9b262973f53709f5bdbc7e2aef8aef6 /lib/Support/Timer.cpp
parentd9bc6a92f55c274b2c1367c7b4c0b721d121bd10 (diff)
downloadexternal_llvm-cd92c1000eeceb195daaab47ca4a2161ab2da410.zip
external_llvm-cd92c1000eeceb195daaab47ca4a2161ab2da410.tar.gz
external_llvm-cd92c1000eeceb195daaab47ca4a2161ab2da410.tar.bz2
Use 64-bit integer counters for tracking time, rather than doubles. This will be more atomic op friendly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Timer.cpp')
-rw-r--r--lib/Support/Timer.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index bcb27a4..f4e97c4 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -112,8 +112,7 @@ static inline size_t getMemUsage() {
}
struct TimeRecord {
- double Elapsed, UserTime, SystemTime;
- ssize_t MemUsed;
+ uint64_t Elapsed, UserTime, SystemTime, MemUsed;
};
static TimeRecord getTimeRecord(bool Start) {
@@ -123,7 +122,7 @@ static TimeRecord getTimeRecord(bool Start) {
sys::TimeValue user(0,0);
sys::TimeValue sys(0,0);
- ssize_t MemUsed = 0;
+ uint64_t MemUsed = 0;
if (Start) {
MemUsed = getMemUsage();
sys::Process::GetTimeUsage(now,user,sys);
@@ -132,9 +131,9 @@ static TimeRecord getTimeRecord(bool Start) {
MemUsed = getMemUsage();
}
- 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.Elapsed = now.seconds() * 1000000 + now.microseconds();
+ Result.UserTime = user.seconds() * 1000000 + user.microseconds();
+ Result.SystemTime = sys.seconds() * 1000000 + sys.microseconds();
Result.MemUsed = MemUsed;
return Result;
@@ -277,12 +276,13 @@ static void printVal(double Val, double Total, std::ostream &OS) {
void Timer::print(const Timer &Total, std::ostream &OS) {
if (Total.UserTime)
- printVal(UserTime, Total.UserTime, OS);
+ printVal(UserTime / 1000000.0, Total.UserTime / 1000000.0, OS);
if (Total.SystemTime)
- printVal(SystemTime, Total.SystemTime, OS);
+ printVal(SystemTime / 1000000.0, Total.SystemTime / 1000000.0, OS);
if (Total.getProcessTime())
- printVal(getProcessTime(), Total.getProcessTime(), OS);
- printVal(Elapsed, Total.Elapsed, OS);
+ printVal(getProcessTime() / 1000000.0,
+ Total.getProcessTime() / 1000000.0, OS);
+ printVal(Elapsed / 1000000.0, Total.Elapsed / 1000000.0, OS);
OS << " ";
@@ -355,23 +355,23 @@ void TimerGroup::removeTimer() {
if (this != DefaultTimerGroup) {
*OutStream << " Total Execution Time: ";
- printAlignedFP(Total.getProcessTime(), 4, 5, *OutStream);
+ printAlignedFP(Total.getProcessTime() / 1000000.0, 4, 5, *OutStream);
*OutStream << " seconds (";
- printAlignedFP(Total.getWallTime(), 4, 5, *OutStream);
+ printAlignedFP(Total.getWallTime() / 1000000.0, 4, 5, *OutStream);
*OutStream << " wall clock)\n";
}
*OutStream << "\n";
- if (Total.UserTime)
+ if (Total.UserTime / 1000000.0)
*OutStream << " ---User Time---";
- if (Total.SystemTime)
+ if (Total.SystemTime / 1000000.0)
*OutStream << " --System Time--";
- if (Total.getProcessTime())
+ if (Total.getProcessTime() / 1000000.0)
*OutStream << " --User+System--";
*OutStream << " ---Wall Time---";
- if (Total.getMemUsed())
+ if (Total.getMemUsed() / 1000000.0)
*OutStream << " ---Mem---";
- if (Total.getPeakMem())
+ if (Total.getPeakMem() / 1000000.0)
*OutStream << " -PeakMem-";
*OutStream << " --- Name ---\n";