Browse Source

Fix some bugs with the EntityProfiler and remove redundant code.

tags/Rel2b
sebas77 6 years ago
parent
commit
6b14cdac13
4 changed files with 6 additions and 26 deletions
  1. +1
    -8
      ECS/EnginesRootEngines.cs
  2. +1
    -13
      ECS/EnginesRootEntities.cs
  3. +1
    -1
      ECS/EnginesRootSubmission.cs
  4. +3
    -4
      ECS/Profiler/EngineProfiler.cs

+ 1
- 8
ECS/EnginesRootEngines.cs View File

@@ -56,9 +56,6 @@ namespace Svelto.ECS
_implementedInterfaceTypes = new Dictionary<Type, Type[]>();
#endif
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
_addEntityViewToEngine = AddEntityViewToEngine;
_removeEntityViewFromEngine = RemoveEntityViewFromEngine;

UnityEngine.GameObject debugEngineObject = new UnityEngine.GameObject("Engine Debugger");
debugEngineObject.gameObject.AddComponent<EngineProfilerBehaviour>();
#endif
@@ -206,11 +203,7 @@ namespace Svelto.ECS

readonly Dictionary<Type, Type[]> _implementedInterfaceTypes;
#endif
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
static Action<IHandleEntityViewEngine, IEntityView> _addEntityViewToEngine;
static Action<IHandleEntityViewEngine, IEntityView> _removeEntityViewFromEngine;
#endif

readonly EngineEntityViewDB _engineEntityViewDB;

class DoubleBufferedEntityViews<T> where T : class, IDictionary, new()


+ 1
- 13
ECS/EnginesRootEntities.cs View File

@@ -222,7 +222,7 @@ namespace Svelto.ECS
for (int j = 0; j < count; j++)
{
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
EngineProfiler.MonitorRemoveDuration(_removeEntityViewFromEngine, fastList[j], entityView);
EngineProfiler.MonitorRemoveDuration(fastList[j], entityView);
#else
fastList[j].Remove(entityView);
#endif
@@ -230,18 +230,6 @@ namespace Svelto.ECS
}
}

#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
static void AddEntityViewToEngine(IHandleEntityViewEngine engine, IEntityView entityView)
{
engine.Add(entityView);
}

static void RemoveEntityViewFromEngine(IHandleEntityViewEngine engine, IEntityView entityView)
{
engine.Remove(entityView);
}
#endif

class GenericEntityFactory : IEntityFactory
{
DataStructures.WeakReference<EnginesRoot> _weakEngine;


+ 1
- 1
ECS/EnginesRootSubmission.cs View File

@@ -148,7 +148,7 @@ namespace Svelto.ECS
for (int j = 0; j < count; j++)
{
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
EngineProfiler.MonitorAddDuration(_addEntityViewToEngine, fastList[j], entityView);
EngineProfiler.MonitorAddDuration(fastList[j], entityView);
#else
fastList[j].Add(entityView);
#endif


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

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

public static void MonitorAddDuration(Action<IHandleEntityViewEngine, IEntityView> addingFunc, IHandleEntityViewEngine engine, IEntityView entityView)
public static void MonitorAddDuration(IHandleEntityViewEngine engine, IEntityView entityView)
{
EngineInfo info;
if (engineInfos.TryGetValue(engine.GetType(), out info))
{
_stopwatch.Start();
addingFunc(engine, entityView);
engine.Add(entityView);
_stopwatch.Reset();

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

public static void MonitorRemoveDuration(Action<IHandleEntityViewEngine, IEntityView> removeFunc, IHandleEntityViewEngine engine, IEntityView entityView)
public static void MonitorRemoveDuration(IHandleEntityViewEngine engine, IEntityView entityView)
{
EngineInfo info;
if (engineInfos.TryGetValue(engine.GetType(), out info))
{
_stopwatch.Start();
removeFunc(engine, entityView);
engine.Remove(entityView);
_stopwatch.Reset();



Loading…
Cancel
Save