blob: f508e6fa1bcbb8aad9ac6232c8da677d0df96d29 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
//===-- Time.cpp ----------------------------------------------------------===//
//
// The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#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);
return (user.seconds() + (double) user.nanoseconds() * 1e-9);
}
double util::getWallTime() {
sys::TimeValue now = getWallTimeVal();
return (now.seconds() + ((double) now.nanoseconds() * 1e-9));
}
sys::TimeValue util::getWallTimeVal() {
return sys::TimeValue::now();
}
#endif
|