Browse Source

fix bug that would have called remove twice when engine profiler was used

remove redundant functions
tags/Rel1
sebas77 6 years ago
parent
commit
488b4a4a84
2 changed files with 5 additions and 17 deletions
  1. +2
    -13
      ECS/EnginesRoot.cs
  2. +3
    -4
      ECS/Profiler/EngineProfiler.cs

+ 2
- 13
ECS/EnginesRoot.cs View File

@@ -376,7 +376,7 @@ namespace Svelto.ECS
for (int j = 0; j < enginesForNode.Count; j++)
{
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
EngineProfiler.MonitorAddDuration(AddNodeToEngine, enginesForNode[j] as INodeEngine, node);
EngineProfiler.MonitorAddDuration(enginesForNode[j] as INodeEngine, node);
#else
(enginesForNode[j] as INodeEngine).Add(node);
#endif
@@ -415,7 +415,7 @@ namespace Svelto.ECS
for (int j = 0; j < enginesForNode.Count; j++)
{
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
EngineProfiler.MonitorRemoveDuration(RemoveNodeFromEngine, (enginesForNode[j] as INodeEngine), node);
EngineProfiler.MonitorRemoveDuration((enginesForNode[j] as INodeEngine), node);
#else
(enginesForNode[j] as INodeEngine).Remove(node);
#endif
@@ -448,17 +448,6 @@ namespace Svelto.ECS
}
}
}
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
void AddNodeToEngine(IEngine engine, INode node)
{
(engine as INodeEngine).Add(node);
}

void RemoveNodeFromEngine(IEngine engine, INode node)
{
(engine as INodeEngine).Remove(node);
}
#endif

void InternalDisable(FasterList<INode> nodes)
{


+ 3
- 4
ECS/Profiler/EngineProfiler.cs View File

@@ -12,28 +12,27 @@ namespace Svelto.ECS.Profiler
{
static readonly Stopwatch _stopwatch = new Stopwatch();

public static void MonitorAddDuration(Action<INodeEngine, INode> addingFunc, INodeEngine engine, INode node)
public static void MonitorAddDuration(INodeEngine engine, INode node)
{
EngineInfo info;
if (engineInfos.TryGetValue(engine.GetType(), out info))
{
_stopwatch.Reset();
_stopwatch.Start();
addingFunc(engine, node);
engine.Add(node);
_stopwatch.Stop();

info.AddAddDuration(_stopwatch.Elapsed.TotalMilliseconds);
}
}

public static void MonitorRemoveDuration(Action<INodeEngine, INode> removeFunc, INodeEngine engine, INode node)
public static void MonitorRemoveDuration(INodeEngine engine, INode node)
{
EngineInfo info;
if (engineInfos.TryGetValue(engine.GetType(), out info))
{
_stopwatch.Reset();
_stopwatch.Start();
removeFunc(engine, node);
engine.Remove(node);
_stopwatch.Stop();


Loading…
Cancel
Save