dev qol: Add fn to make Stopwatch and start it at once

This commit is contained in:
John Colvin committed 2025-06-09 05:58:37 +00:00
1 parent 237f525263
commit 2dec5812f6
1 file changed
+12
+12
View File
@@ -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());