Quick hack to reduce sim slowdown during save (#375)

This commit is contained in:
Brant Martin
2020-04-09 11:32:23 -04:00
committed by GitHub
parent 035325da22
commit 76ea5fdbc1

View File

@@ -52,6 +52,9 @@ namespace Torch.Server
internal bool FatalException { get; set; } internal bool FatalException { get; set; }
private System.Timers.Timer _simUpdateTimer = new System.Timers.Timer(200);
private bool _simDirty;
/// <inheritdoc /> /// <inheritdoc />
public TorchServer(TorchConfig config = null) public TorchServer(TorchConfig config = null)
{ {
@@ -68,12 +71,36 @@ namespace Torch.Server
// where the debug listeners are registered // where the debug listeners are registered
if (!((TorchConfig)Config).EnableAsserts) if (!((TorchConfig)Config).EnableAsserts)
MyDebug.Listeners.Clear(); MyDebug.Listeners.Clear();
_simUpdateTimer.Elapsed += SimUpdateElapsed;
_simUpdateTimer.Start();
} }
private void SimUpdateElapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (_simDirty)
{
OnPropertyChanged(nameof(SimulationRatio));
_simDirty = false;
}
}
public bool HasRun { get => _hasRun; set => SetValue(ref _hasRun, value); } public bool HasRun { get => _hasRun; set => SetValue(ref _hasRun, value); }
/// <inheritdoc /> /// <inheritdoc />
public float SimulationRatio { get => _simRatio; set => SetValue(ref _simRatio, value); } public float SimulationRatio
{
get => _simRatio;
set
{
if (_simRatio.IsEqual(value, 0.01f))
return;
_simRatio = value;
_simDirty = true;
//SetValue(ref _simRatio, value);
}
}
/// <inheritdoc /> /// <inheritdoc />
public TimeSpan ElapsedPlayTime { get => _elapsedPlayTime; set => SetValue(ref _elapsedPlayTime, value); } public TimeSpan ElapsedPlayTime { get => _elapsedPlayTime; set => SetValue(ref _elapsedPlayTime, value); }