diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2017-06-07 13:36:28 +0200 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2018-09-18 10:36:36 +0100 |
commit | b2659ec04a9814718736ad960635a9a28edd6078 (patch) | |
tree | 5b7b383549644760782be0d23b827968decd4694 /lib/Support/Time.cpp | |
parent | bad4c5083b3e160abfaa84ede071c5e69d1f2709 (diff) | |
download | klee-b2659ec04a9814718736ad960635a9a28edd6078.tar.gz |
llvm4: use chrono helpers from LLVM
LLVM 4 removes the old time interface and starts using the C++11's chrono. So switch to that in klee for LLVM 4 too. Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'lib/Support/Time.cpp')
-rw-r--r-- | lib/Support/Time.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Support/Time.cpp b/lib/Support/Time.cpp index be5eaf18..f508e6fa 100644 --- a/lib/Support/Time.cpp +++ b/lib/Support/Time.cpp @@ -10,12 +10,43 @@ #include "klee/Config/Version.h" #include "klee/Internal/System/Time.h" +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include <chrono> + +#include <llvm/Support/Chrono.h> +#else #include "llvm/Support/TimeValue.h" +#endif + #include "llvm/Support/Process.h" using namespace llvm; using namespace klee; +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +double util::durationToDouble(std::chrono::nanoseconds dur) +{ + return dur.count() / 1e9; +} + +double util::getUserTime() { + sys::TimePoint<> now; + std::chrono::nanoseconds user, sys; + + sys::Process::GetTimeUsage(now, user, sys); + + return durationToDouble(user); +} + +double util::getWallTime() { + return durationToDouble(getWallTimeVal().time_since_epoch()); +} + +sys::TimePoint<> util::getWallTimeVal() { + return std::chrono::system_clock::now(); +} + +#else double util::getUserTime() { sys::TimeValue now(0,0),user(0,0),sys(0,0); sys::Process::GetTimeUsage(now,user,sys); @@ -30,3 +61,4 @@ double util::getWallTime() { sys::TimeValue util::getWallTimeVal() { return sys::TimeValue::now(); } +#endif |