Skip to content

Commit

Permalink
Additional fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhjp01 committed May 7, 2024
1 parent d584596 commit 05c4ecc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/cosim/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class real_time_timer::impl
void update_rolling_average_real_time_factor(
Time::time_point& currentTime,
time_point& currentSimulationTime,
const duration& elapsedRealTime)
const cosim::duration& elapsedRealTime)
{
const auto elapsedSimTime =
tick_period_match_ ? currentSimulationTime - rtSimulationStartTime_ : std::chrono::duration_cast<duration>(currentSimulationTime - rtSimulationStartTime_);
tick_period_match_ ? currentSimulationTime - rtSimulationStartTime_ : std::chrono::duration_cast<cosim::duration>(currentSimulationTime - rtSimulationStartTime_);

metrics_->rolling_average_real_time_factor = elapsedSimTime.count() / (1.0 * elapsedRealTime.count());
rtStartTime_ = currentTime;
Expand All @@ -97,14 +97,15 @@ class real_time_timer::impl
void update_real_time_factor(Time::time_point currentTime, time_point currentSimulationTime)
{
const auto relativeSimTime =
tick_period_match_ ? currentSimulationTime - simulationStartTime_ : std::chrono::duration_cast<duration>(currentSimulationTime - simulationStartTime_);
tick_period_match_ ? currentSimulationTime - simulationStartTime_ : std::chrono::duration_cast<cosim::duration>(currentSimulationTime - simulationStartTime_);
const auto relativeRealTime =
tick_period_match_ ? currentTime - startTime_ : std::chrono::duration_cast<duration>(currentTime - startTime_);
tick_period_match_ ? currentTime - startTime_ : std::chrono::duration_cast<cosim::duration>(currentTime - startTime_);

metrics_->total_average_real_time_factor = relativeSimTime.count() / (1.0 * relativeRealTime.count());

if (sampling_period_to_monitor_.has_value()) {
const auto elapsedRealTime = currentTime - rtStartTime_;
const auto elapsedRealTime =
tick_period_match_ ? currentTime - rtStartTime_ : std::chrono::duration_cast<cosim::duration>(currentTime - rtStartTime_);

if (elapsedRealTime > sampling_period_to_monitor_.value()) {
update_rolling_average_real_time_factor(currentTime, currentSimulationTime, elapsedRealTime);
Expand Down

0 comments on commit 05c4ecc

Please sign in to comment.