3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-13 12:28:44 +00:00

simplify timer.h

This commit is contained in:
Nuno Lopes 2019-02-21 13:57:38 +00:00
parent 3a7c467822
commit 85162d90d1
2 changed files with 18 additions and 50 deletions

View file

@ -1,40 +0,0 @@
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
timer.cpp
Abstract:
<abstract>
Author:
Leonardo de Moura (leonardo) 2009-01-06.
Revision History:
--*/
#include "util/util.h"
#include "util/memory_manager.h"
#include "util/stopwatch.h"
#include "util/timer.h"
timer::timer(){
m_watch = alloc(stopwatch);
start();
}
timer::~timer() {
dealloc(m_watch);
}
void timer::start() {
m_watch->start();
}
double timer::get_seconds() {
return m_watch->get_current_seconds();
}

View file

@ -19,21 +19,29 @@ Revision History:
#ifndef TIMER_H_
#define TIMER_H_
class stopwatch;
#include "util/stopwatch.h"
/**
\brief Wrapper for the stopwatch class. It hides windows.h dependency.
\brief Wrapper for the stopwatch class.
*/
class timer {
stopwatch * m_watch;
stopwatch m_watch;
public:
timer();
~timer();
void start();
double get_seconds();
bool timeout(unsigned secs) { return secs > 0 && secs != UINT_MAX && get_seconds() > secs; }
bool ms_timeout(unsigned ms) { return ms > 0 && ms != UINT_MAX && get_seconds() * 1000 > ms; }
void start() {
m_watch.start();
}
double get_seconds() const {
return m_watch.get_current_seconds();
}
bool timeout(unsigned secs) const {
return secs != 0 && secs != UINT_MAX && get_seconds() > secs;
}
bool ms_timeout(unsigned ms) const {
return ms != 0 && ms != UINT_MAX && get_seconds() * 1000 > ms;
}
};
#endif /* TIMER_H_ */