perf: RunSimulation支持自定义TimeScale + 删除诊断dump + 批量commit
- RunSimulation 增加 timeScale 参数(默认8f) - 删除 fireSchedule 诊断 dump 到桌面 - Commit 批量50帧
This commit is contained in:
parent
197f8b6e5c
commit
2162a342b7
@ -47,27 +47,12 @@ namespace CounterDrone.Core.Tests
|
||||
if (Directory.Exists(_testDir)) Directory.Delete(_testDir, true);
|
||||
}
|
||||
|
||||
private SimulationEngine RunSimulation(int maxTicks, float tickDt = 1f / 20f)
|
||||
private SimulationEngine RunSimulation(int maxTicks, float tickDt = 1f / 20f, float timeScale = 8f)
|
||||
{
|
||||
var engine = new SimulationEngine(_scenario, _frameStore, new DamageModelRouter(), _paths, new DefaultDefensePlanner(_ammoCatalog));
|
||||
|
||||
engine.Initialize(_taskId);
|
||||
|
||||
// 诊断:检查 _fireSchedule 的时序
|
||||
var fld = typeof(SimulationEngine).GetField("_fireSchedule", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
if (fld != null)
|
||||
{
|
||||
var schedule = fld.GetValue(engine) as System.Collections.IList;
|
||||
if (schedule != null && schedule.Count > 0)
|
||||
{
|
||||
var ftimes = schedule.Cast<object>().Select(e => ((dynamic)e).FireTime).Cast<float>().ToList();
|
||||
System.IO.File.WriteAllText(@"C:\Users\Tellme\Desktop\schedule_dump.txt",
|
||||
$"count={schedule.Count} first={ftimes.Min():F3} last={ftimes.Max():F3} span={ftimes.Max()-ftimes.Min():F3}\n" +
|
||||
string.Join("\n", ftimes.Select((t,i) => $"{t:F3}")));
|
||||
}
|
||||
}
|
||||
|
||||
engine.TimeScale = 8f; // 8倍速加速
|
||||
engine.TimeScale = timeScale; // 8倍速加速
|
||||
for (int i = 0; i < maxTicks; i++)
|
||||
{
|
||||
var r = engine.Tick(tickDt);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user