mirror of
https://github.com/Z3Prover/z3
synced 2025-08-09 20:50:50 +00:00
Restore expected behavior to stopwatch
This commit is contained in:
parent
e816d16724
commit
7823117776
1 changed files with 14 additions and 11 deletions
|
@ -30,9 +30,7 @@ class stopwatch
|
||||||
|
|
||||||
clock_t m_start;
|
clock_t m_start;
|
||||||
duration_t m_elapsed;
|
duration_t m_elapsed;
|
||||||
#if Z3DEBUG
|
|
||||||
bool m_running = false;
|
bool m_running = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
// FIXME: just use auto with VS 2015+
|
// FIXME: just use auto with VS 2015+
|
||||||
static clock_t get() {
|
static clock_t get() {
|
||||||
|
@ -50,27 +48,32 @@ public:
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
m_elapsed = duration_t::zero();
|
m_elapsed = duration_t::zero();
|
||||||
DEBUG_CODE(m_running = false;);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
// SASSERT(!m_running);
|
if (!m_running) {
|
||||||
DEBUG_CODE(m_running = true;);
|
m_start = get();
|
||||||
m_start = get();
|
m_running = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop() {
|
void stop() {
|
||||||
// SASSERT(m_running);
|
if (m_running) {
|
||||||
DEBUG_CODE(m_running = false;);
|
m_elapsed += get() - m_start;
|
||||||
m_elapsed += get() - m_start;
|
m_running = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_seconds() const {
|
double get_seconds() const {
|
||||||
|
if (m_running) {
|
||||||
|
const_cast<stopwatch*>(this)->stop();
|
||||||
|
const_cast<stopwatch*>(this)->start();
|
||||||
|
}
|
||||||
return std::chrono::duration_cast<std::chrono::milliseconds>(m_elapsed).count() / 1000.0;
|
return std::chrono::duration_cast<std::chrono::milliseconds>(m_elapsed).count() / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_current_seconds() const {
|
double get_current_seconds() const {
|
||||||
return std::chrono::duration_cast<std::chrono::milliseconds>(get() - m_start).count() / 1000.0;
|
return get_seconds();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue