Skip to content

Commit

Permalink
Add amici.CpuTimer.uses_thread_clock to check at runtime whether we a…
Browse files Browse the repository at this point in the history
…re using thread_clock
  • Loading branch information
dweindl committed Aug 24, 2023
1 parent 9151f87 commit 0db688f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/amici/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ template <class T> bool is_equal(T const& a, T const& b) {
}

#ifdef BOOST_CHRONO_HAS_THREAD_CLOCK
/** Tracks elapsed CPU time. */
/** Tracks elapsed CPU time using boost::chrono::thread_clock. */
class CpuTimer {
using clock = boost::chrono::thread_clock;
using time_point = clock::time_point;
Expand Down Expand Up @@ -291,12 +291,14 @@ class CpuTimer {
return d_milliseconds(clock::now() - start_).count();
}

static const bool uses_thread_clock = true;

private:
/** Start time */
time_point start_;
};
#else
/** Tracks elapsed CPU time. */
/** Tracks elapsed CPU time using std::clock. */
class CpuTimer {
public:
/**
Expand Down Expand Up @@ -328,6 +330,8 @@ class CpuTimer {
/ CLOCKS_PER_SEC;
}

static const bool uses_thread_clock = false;

private:
/** Start time */
std::clock_t start_;
Expand Down

0 comments on commit 0db688f

Please sign in to comment.