diff options
author | Pavel Labath <labath@google.com> | 2016-10-24 10:59:17 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2016-10-24 10:59:17 +0000 |
commit | 757ca886cd224726d43333d44b5b2ce0989b7f1c (patch) | |
tree | d7416c65b01b7532a708d98fa3ac7a3b2dcab1ce /llvm/lib/Support/Timer.cpp | |
parent | 407fd070b776b2c600d53ebb83cb1f4291496606 (diff) | |
download | llvm-757ca886cd224726d43333d44b5b2ce0989b7f1c.zip llvm-757ca886cd224726d43333d44b5b2ce0989b7f1c.tar.gz llvm-757ca886cd224726d43333d44b5b2ce0989b7f1c.tar.bz2 |
Remove TimeValue usage from llvm/Support
Summary:
This is a follow-up to D25416. It removes all usages of TimeValue from
llvm/Support library (except for the actual TimeValue declaration), and replaces
them with appropriate usages of std::chrono. To facilitate this, I have added
small utility functions for converting time points and durations into appropriate
OS-specific types (FILETIME, struct timespec, ...).
Reviewers: zturner, mehdi_amini
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25730
llvm-svn: 284966
Diffstat (limited to 'llvm/lib/Support/Timer.cpp')
-rw-r--r-- | llvm/lib/Support/Timer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index ee2bdb0..afb16ca 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -116,8 +116,10 @@ static inline size_t getMemUsage() { } TimeRecord TimeRecord::getCurrentTime(bool Start) { + using Seconds = std::chrono::duration<double, std::ratio<1>>; TimeRecord Result; - sys::TimeValue now(0,0), user(0,0), sys(0,0); + sys::TimePoint<> now; + std::chrono::nanoseconds user, sys; if (Start) { Result.MemUsed = getMemUsage(); @@ -127,9 +129,9 @@ TimeRecord TimeRecord::getCurrentTime(bool Start) { Result.MemUsed = getMemUsage(); } - Result.WallTime = now.seconds() + now.microseconds() / 1000000.0; - Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; - Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; + Result.WallTime = Seconds(now.time_since_epoch()).count(); + Result.UserTime = Seconds(user).count(); + Result.SystemTime = Seconds(sys).count(); return Result; } |