dev qol: Add fn to make Stopwatch and start it at once
This commit is contained in:
1 parent
237f525263
commit
2dec5812f6
1 file changed
+12
@@ -18,6 +18,12 @@ struct Stopwatch {
|
||||
std::vector<Stopwatch_Lap> laps;
|
||||
bool is_running = false;
|
||||
|
||||
static Stopwatch start_new() {
|
||||
Stopwatch sw;
|
||||
sw.start();
|
||||
return sw;
|
||||
}
|
||||
|
||||
core::TimeSpan elapsed() const {
|
||||
if (is_running) {
|
||||
return core::TimeStamp::now() - start_time;
|
||||
@@ -54,6 +60,12 @@ struct Stopwatch {
|
||||
start_time = core::TimeStamp::now();
|
||||
}
|
||||
|
||||
void restart() {
|
||||
is_running = false;
|
||||
laps.clear();
|
||||
start();
|
||||
}
|
||||
|
||||
Stopwatch &lap() {
|
||||
if (is_running) {
|
||||
laps.emplace_back(start_time, core::TimeStamp::now());
|
||||
|
||||
Reference in new issue
Block a user