timer: use monotonic clock and accumulate walltime
Fixes #439 * spot/misc/timer.hh: here
This commit is contained in:
parent
d7871e549e
commit
71060db9dd
1 changed files with 6 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ namespace spot
|
||||||
struct stopwatch
|
struct stopwatch
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef std::chrono::high_resolution_clock clock;
|
typedef std::chrono::steady_clock clock;
|
||||||
clock::time_point start_;
|
clock::time_point start_;
|
||||||
public:
|
public:
|
||||||
/// Marks the start if the measurement
|
/// Marks the start if the measurement
|
||||||
|
|
@ -96,7 +96,7 @@ namespace spot
|
||||||
{
|
{
|
||||||
SPOT_ASSERT(!running);
|
SPOT_ASSERT(!running);
|
||||||
running = true;
|
running = true;
|
||||||
wall_start_ = std::chrono::high_resolution_clock::now();
|
wall_start_ = std::chrono::steady_clock::now();
|
||||||
#ifdef SPOT_HAVE_TIMES
|
#ifdef SPOT_HAVE_TIMES
|
||||||
struct tms tmp;
|
struct tms tmp;
|
||||||
times(&tmp);
|
times(&tmp);
|
||||||
|
|
@ -113,8 +113,8 @@ namespace spot
|
||||||
void
|
void
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
auto end = std::chrono::steady_clock::now();
|
||||||
wall_cumul_ = std::chrono::duration_cast
|
wall_cumul_ += std::chrono::duration_cast
|
||||||
<std::chrono::milliseconds>(end - wall_start_).count();
|
<std::chrono::milliseconds>(end - wall_start_).count();
|
||||||
#ifdef SPOT_HAVE_TIMES
|
#ifdef SPOT_HAVE_TIMES
|
||||||
struct tms tmp;
|
struct tms tmp;
|
||||||
|
|
@ -213,8 +213,8 @@ namespace spot
|
||||||
time_info start_;
|
time_info start_;
|
||||||
time_info total_;
|
time_info total_;
|
||||||
bool running;
|
bool running;
|
||||||
std::chrono::high_resolution_clock::time_point wall_start_;
|
std::chrono::steady_clock::time_point wall_start_;
|
||||||
std::chrono::milliseconds::rep wall_cumul_;
|
std::chrono::milliseconds::rep wall_cumul_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This function declared here must be implemented in each file
|
// This function declared here must be implemented in each file
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue