diff --git a/src/lib_spark/spark/utils/stopwatch.h b/src/lib_spark/spark/utils/stopwatch.h index 06d614e94..43395f26f 100644 --- a/src/lib_spark/spark/utils/stopwatch.h +++ b/src/lib_spark/spark/utils/stopwatch.h @@ -18,6 +18,12 @@ struct Stopwatch { std::vector 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());