Skip to content

Commit

Permalink
fix timer
Browse files Browse the repository at this point in the history
  • Loading branch information
5had3z committed May 27, 2024
1 parent 0d52b5d commit 3907cea
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace cvt {

static FrequencyTimer gTimer("Converter", std::chrono::seconds(30));

template<> void BaseConverter<ReplayDataSoA>::clear() noexcept
{
replayData_.data.clear();
Expand Down Expand Up @@ -125,10 +127,6 @@ template<> void BaseConverter<ReplayDataSoA>::copyDynamicMapData() noexcept

template<> void BaseConverter<ReplayDataSoA>::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(); }

Expand All @@ -147,6 +145,8 @@ template<> void BaseConverter<ReplayDataSoA>::copyCommonData() noexcept

template<> void FullConverter<ReplayDataSoA>::OnStep()
{
gTimer.step(fmt::format("Step {} of {}", this->Observation()->GetGameLoop(), replayData_.header.durationSteps));

// "Initialize" next item
replayData_.data.resize(replayData_.data.size() + 1);

Expand All @@ -158,6 +158,8 @@ template<> void FullConverter<ReplayDataSoA>::OnStep()

template<> void ActionConverter<ReplayDataSoA>::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); }

Expand All @@ -175,6 +177,8 @@ template<> void ActionConverter<ReplayDataSoA>::OnStep()

template<> void StridedConverter<ReplayDataSoA>::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;
Expand Down

0 comments on commit 3907cea

Please sign in to comment.