From 3907cea81ea0e4dbdfee9080c69a2b660ff7794a Mon Sep 17 00:00:00 2001 From: 5had3z <59598353+5had3z@users.noreply.github.com> Date: Mon, 27 May 2024 14:54:28 +1000 Subject: [PATCH] fix timer --- src/observer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/observer.cpp b/src/observer.cpp index f6deb11..adb462b 100644 --- a/src/observer.cpp +++ b/src/observer.cpp @@ -9,6 +9,8 @@ namespace cvt { +static FrequencyTimer gTimer("Converter", std::chrono::seconds(30)); + template<> void BaseConverter::clear() noexcept { replayData_.data.clear(); @@ -125,10 +127,6 @@ template<> void BaseConverter::copyDynamicMapData() noexcept template<> void BaseConverter::copyCommonData() noexcept { - // Logging performance - static FrequencyTimer timer("Converter", std::chrono::seconds(30)); - timer.step(fmt::format("Step {} of {}", this->Observation()->GetGameLoop(), replayData_.header.durationSteps)); - // Copy static height map if not already done if (replayData_.header.heightMap.empty()) { this->copyHeightMapData(); } @@ -147,6 +145,8 @@ template<> void BaseConverter::copyCommonData() noexcept template<> void FullConverter::OnStep() { + gTimer.step(fmt::format("Step {} of {}", this->Observation()->GetGameLoop(), replayData_.header.durationSteps)); + // "Initialize" next item replayData_.data.resize(replayData_.data.size() + 1); @@ -158,6 +158,8 @@ template<> void FullConverter::OnStep() template<> void ActionConverter::OnStep() { + gTimer.step(fmt::format("Step {} of {}", this->Observation()->GetGameLoop(), replayData_.header.durationSteps)); + // Need to have at least one buffer if (replayData_.data.empty()) { replayData_.data.resize(1); } @@ -175,6 +177,8 @@ template<> void ActionConverter::OnStep() template<> void StridedConverter::OnStep() { + gTimer.step(fmt::format("Step {} of {}", this->Observation()->GetGameLoop(), replayData_.header.durationSteps)); + // Check if a logging step const auto gameStep = this->Observation()->GetGameLoop(); bool shouldRecord = gameStep % stride_ == 0;