about summary refs log tree commit diff homepage
path: root/lib/Support/Timer.cpp
blob: 0e727bb4a1c4af155a6285f1db1e1f67de2ce9f1 (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
//===-- Timer.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/Support/Timer.h"

#include "klee/Internal/System/Time.h"

using namespace klee;
using namespace llvm;

#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)

WallTimer::WallTimer() {
  start = util::getWallTimeVal();
}

uint64_t WallTimer::check() {
  auto now = util::getWallTimeVal();
  return std::chrono::duration_cast<std::chrono::microseconds>(now -
    start).count();
}

#else

WallTimer::WallTimer() {
  startMicroseconds = util::getWallTimeVal().usec();
}

uint64_t WallTimer::check() {
  return util::getWallTimeVal().usec() - startMicroseconds;
}

#endif