forked from quickshell/quickshell
core/elapsedtimer: add ElapsedTimer
This commit is contained in:
parent
37fecfc990
commit
be237b6ab5
4 changed files with 69 additions and 0 deletions
22
src/core/elapsedtimer.cpp
Normal file
22
src/core/elapsedtimer.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "elapsedtimer.hpp"
|
||||
|
||||
#include <qtypes.h>
|
||||
|
||||
ElapsedTimer::ElapsedTimer() { this->timer.start(); }
|
||||
|
||||
qreal ElapsedTimer::elapsed() { return static_cast<qreal>(this->elapsedNs()) / 1000000000.0; }
|
||||
|
||||
qreal ElapsedTimer::restart() { return static_cast<qreal>(this->restartNs()) / 1000000000.0; }
|
||||
|
||||
qint64 ElapsedTimer::elapsedMs() { return this->timer.elapsed(); }
|
||||
|
||||
qint64 ElapsedTimer::restartMs() { return this->timer.restart(); }
|
||||
|
||||
qint64 ElapsedTimer::elapsedNs() { return this->timer.nsecsElapsed(); }
|
||||
|
||||
qint64 ElapsedTimer::restartNs() {
|
||||
// see qelapsedtimer.cpp
|
||||
auto old = this->timer;
|
||||
this->timer.start();
|
||||
return old.durationTo(this->timer).count();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue