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

This commit is contained in:
John Colvin committed 2025-06-13 20:50:29 +00:00
1 parent e48f2ec99d
commit bfeb5e362a
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());