delphyne
|
A class that keeps statistics on a interactive simulation session An interactive session is usually composed of one or more simulation runs, depending on the interactions with the external world.
As an example consider the following scenario, where the simulation step is of 1ms:
For this case, the interactive simulation statistics would be composed of three runs:
Hence the total numbers would be:
Note that T1 and T2 are not considered, as during those time the simulation was idle.
#include <src/backend/interactive_simulation_stats.h>
Public Member Functions | |
DELPHYNE_NO_COPY_NO_MOVE_NO_ASSIGN (InteractiveSimulationStats) | |
InteractiveSimulationStats ()=default | |
void | NewRunStartingAt (double start_simtime, double expected_realtime_rate) |
Creates a new simulation run, starting at start_simtime More... | |
void | NewRunStartingAt (double start_simtime, double expected_realtime_rate, const TimePoint &start_realtime) |
Creates a new simulation run, starting at start_simtime More... | |
TimePoint | StepExecuted (double simtime) |
Records that a step was executed by the simulator and records it as part of the current simulation run. More... | |
void | RealtimeStepExecuted (const TimePoint &realtime) |
Sets the time when the step is completed and records it as part of the current simulation run. More... | |
void | RealtimeStepExecuted () |
Sets the time when the step is completed and records it as part of the current simulation run. More... | |
SimulationRunStats | GetCurrentRunStats () const |
Returns a copy of the current running simulation stats. More... | |
double | TotalElapsedSimtime () const |
Returns the sum of the elapsed simulation time of all the simulation runs. More... | |
double | TotalElapsedRealtime () const |
Returns the sum of the elapsed real time of all the simulation runs. More... | |
int | TotalExecutedSteps () const |
Returns the sum of the executed steps of all the simulation runs. More... | |
int | TotalRuns () const |
Returns the number of simulation runs. More... | |
double | get_current_realtime_rate () const |
Returns the current real-time rate by doing a weighted cumulative sum. More... | |
|
default |
DELPHYNE_NO_COPY_NO_MOVE_NO_ASSIGN | ( | InteractiveSimulationStats | ) |
double get_current_realtime_rate | ( | ) | const |
Returns the current real-time rate by doing a weighted cumulative sum.
We use this method instead of just dividing total_elapsed_simtime_
by total_elapsed_simtime_
because that would require a long time to adjust to real-time rate changes. As an example of this behavior consider an interactive simulation configured with a 1ms simulation step. Assuming that it starts with a simulation run of 100 seconds at 1.0 real-time, ff we then change the real-time rate to 0.1, after the first execution step we would have:
In contrast, by using a weighted cumulative sum to compute the real-time rate, the latest steps are given more importance in the computation, allowing the rate to quickly update to configuration changes. Continuing with the above example and using a 0.5 weighing factor, in only 15 steps the real-time rate drops to ~0.102, closely matching our 0.1 configured factor.
SimulationRunStats GetCurrentRunStats | ( | ) | const |
Returns a copy of the current running simulation stats.
void NewRunStartingAt | ( | double | start_simtime, |
double | expected_realtime_rate | ||
) |
Creates a new simulation run, starting at start_simtime
[in] | start_simtime | The time the simulation started, given by the simulator clock. |
[in] | expected_realtime_rate | The desired real time based in the simulation runner configuration. |
void NewRunStartingAt | ( | double | start_simtime, |
double | expected_realtime_rate, | ||
const TimePoint & | start_realtime | ||
) |
Creates a new simulation run, starting at start_simtime
[in] | start_simtime | The time the simulation started, given by the simulator clock. |
[in] | expected_realtime_rate | The desired real time based in the simulation runner configuration. |
[in] | start_realtime | The time the simulation started, given by the real-time clock. |
void RealtimeStepExecuted | ( | ) |
Sets the time when the step is completed and records it as part of the current simulation run.
void RealtimeStepExecuted | ( | const TimePoint & | realtime | ) |
Sets the time when the step is completed and records it as part of the current simulation run.
[in] | realtime | The time the step took to execute, given by the wall clock. |
TimePoint StepExecuted | ( | double | simtime | ) |
Records that a step was executed by the simulator and records it as part of the current simulation run.
Assumes that the realtime counterpart is the current time.
[in] | simtime | The time the step was executed, in seconds, given by the simulator clock. |
double TotalElapsedRealtime | ( | ) | const |
Returns the sum of the elapsed real time of all the simulation runs.
double TotalElapsedSimtime | ( | ) | const |
Returns the sum of the elapsed simulation time of all the simulation runs.
int TotalExecutedSteps | ( | ) | const |
Returns the sum of the executed steps of all the simulation runs.
int TotalRuns | ( | ) | const |
Returns the number of simulation runs.