mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
Add profile markers for builtin runners
This commit is contained in:
parent
aa80699f5a
commit
eb7f1836aa
@ -21,30 +21,126 @@
|
|||||||
|
|
||||||
public sealed class EcsPreInitRunner : EcsRunner<IEcsPreInitSystem>, IEcsPreInitSystem
|
public sealed class EcsPreInitRunner : EcsRunner<IEcsPreInitSystem>, IEcsPreInitSystem
|
||||||
{
|
{
|
||||||
void IEcsPreInitSystem.PreInit(EcsSystems systems)
|
#if DEBUG
|
||||||
|
private int[] _targetIds;
|
||||||
|
#endif
|
||||||
|
public void PreInit(EcsSystems systems)
|
||||||
{
|
{
|
||||||
foreach (var item in targets) item.PreInit(systems);
|
#if DEBUG
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
int id = _targetIds[i];
|
||||||
|
EcsDebug.ProfileMarkBegin(id);
|
||||||
|
targets[i].PreInit(systems);
|
||||||
|
EcsDebug.ProfileMarkEnd(id);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
foreach (var item in targets) item.PreInit(systems);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
protected override void OnSetup()
|
||||||
|
{
|
||||||
|
_targetIds = new int[targets.Length];
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
_targetIds[i] = EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
public sealed class EcsInitRunner : EcsRunner<IEcsInitSystem>, IEcsInitSystem
|
public sealed class EcsInitRunner : EcsRunner<IEcsInitSystem>, IEcsInitSystem
|
||||||
{
|
{
|
||||||
void IEcsInitSystem.Init(EcsSystems systems)
|
#if DEBUG
|
||||||
|
private int[] _targetIds;
|
||||||
|
#endif
|
||||||
|
public void Init(EcsSystems systems)
|
||||||
{
|
{
|
||||||
foreach (var item in targets) item.Init(systems);
|
#if DEBUG
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
int id = _targetIds[i];
|
||||||
|
EcsDebug.ProfileMarkBegin(id);
|
||||||
|
targets[i].Init(systems);
|
||||||
|
EcsDebug.ProfileMarkEnd(id);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
foreach (var item in targets) item.Init(systems);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
protected override void OnSetup()
|
||||||
|
{
|
||||||
|
_targetIds = new int[targets.Length];
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
_targetIds[i] = EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
public sealed class EcsRunRunner : EcsRunner<IEcsRunSystem>, IEcsRunSystem
|
public sealed class EcsRunRunner : EcsRunner<IEcsRunSystem>, IEcsRunSystem
|
||||||
{
|
{
|
||||||
void IEcsRunSystem.Run(EcsSystems systems)
|
#if DEBUG
|
||||||
|
private int[] _targetIds;
|
||||||
|
#endif
|
||||||
|
public void Run(EcsSystems systems)
|
||||||
{
|
{
|
||||||
foreach (var item in targets) item.Run(systems);
|
#if DEBUG
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
int id = _targetIds[i];
|
||||||
|
EcsDebug.ProfileMarkBegin(id);
|
||||||
|
targets[i].Run(systems);
|
||||||
|
EcsDebug.ProfileMarkEnd(id);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
foreach (var item in targets) item.Run(systems);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
protected override void OnSetup()
|
||||||
|
{
|
||||||
|
_targetIds = new int[targets.Length];
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
_targetIds[i] = EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
public sealed class EcsDestroyRunner : EcsRunner<IEcsDestroySystem>, IEcsDestroySystem
|
public sealed class EcsDestroyRunner : EcsRunner<IEcsDestroySystem>, IEcsDestroySystem
|
||||||
{
|
{
|
||||||
void IEcsDestroySystem.Destroy(EcsSystems systems)
|
#if DEBUG
|
||||||
|
private int[] _targetIds;
|
||||||
|
#endif
|
||||||
|
public void Destroy(EcsSystems systems)
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
int id = _targetIds[i];
|
||||||
|
EcsDebug.ProfileMarkBegin(id);
|
||||||
|
targets[i].Destroy(systems);
|
||||||
|
EcsDebug.ProfileMarkEnd(id);
|
||||||
|
}
|
||||||
|
#else
|
||||||
foreach (var item in targets) item.Destroy(systems);
|
foreach (var item in targets) item.Destroy(systems);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
protected override void OnSetup()
|
||||||
|
{
|
||||||
|
_targetIds = new int[targets.Length];
|
||||||
|
for (int i = 0; i < targets.Length; i++)
|
||||||
|
{
|
||||||
|
_targetIds[i] = EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -11,13 +11,16 @@ namespace DCFApixels.DragonECS
|
|||||||
public static void Set(DebugService service) => DebugService.Set(service);
|
public static void Set(DebugService service) => DebugService.Set(service);
|
||||||
|
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print(object v) => DebugService.Instance.Print(v);
|
public static void Print(object v) => DebugService.Instance.Print(v);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print(string tag, object v)
|
public static void Print(string tag, object v)
|
||||||
{
|
{
|
||||||
#if !DISABLE_ECS_DEBUG
|
#if !DISABLE_ECS_DEBUG
|
||||||
DebugService.Instance.Print(tag, v);
|
DebugService.Instance.Print(tag, v);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static int RegisterMark(string name)
|
public static int RegisterMark(string name)
|
||||||
{
|
{
|
||||||
#if !DISABLE_ECS_DEBUG
|
#if !DISABLE_ECS_DEBUG
|
||||||
@ -26,18 +29,21 @@ namespace DCFApixels.DragonECS
|
|||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void DeleteMark(string name)
|
public static void DeleteMark(string name)
|
||||||
{
|
{
|
||||||
#if !DISABLE_ECS_DEBUG
|
#if !DISABLE_ECS_DEBUG
|
||||||
DebugService.Instance.DeleteMark(name);
|
DebugService.Instance.DeleteMark(name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void ProfileMarkBegin(int id)
|
public static void ProfileMarkBegin(int id)
|
||||||
{
|
{
|
||||||
#if !DISABLE_ECS_DEBUG
|
#if !DISABLE_ECS_DEBUG
|
||||||
DebugService.Instance.ProfileMarkBegin(id);
|
DebugService.Instance.ProfileMarkBegin(id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static double ProfileMarkEnd(int id)
|
public static double ProfileMarkEnd(int id)
|
||||||
{
|
{
|
||||||
#if !DISABLE_ECS_DEBUG
|
#if !DISABLE_ECS_DEBUG
|
||||||
@ -71,17 +77,15 @@ namespace DCFApixels.DragonECS
|
|||||||
OnServiceChanged(_instance);
|
OnServiceChanged(_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Action<DebugService> OnServiceChanged = delegate { };
|
public static Action<DebugService> OnServiceChanged = delegate { };
|
||||||
|
|
||||||
|
|
||||||
private IntDispenser _idDispenser = new IntDispenser(0);
|
private IntDispenser _idDispenser = new IntDispenser(0);
|
||||||
private Dictionary<string, int> _nameIdTable = new Dictionary<string, int>();
|
private Dictionary<string, int> _nameIdTable = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Print(object v) => Print(null, v);
|
public void Print(object v) => Print(null, v);
|
||||||
public abstract void Print(string tag, object v);
|
public abstract void Print(string tag, object v);
|
||||||
|
|
||||||
|
|
||||||
public int RegisterMark(string name)
|
public int RegisterMark(string name)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
@ -107,8 +111,6 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public abstract void ProfileMarkBegin(int id);
|
public abstract void ProfileMarkBegin(int id);
|
||||||
public abstract double ProfileMarkEnd(int id);
|
public abstract double ProfileMarkEnd(int id);
|
||||||
|
|
||||||
// public abstract IEnumerable<>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class DefaultDebugService : DebugService
|
public sealed class DefaultDebugService : DebugService
|
||||||
|
Loading…
Reference in New Issue
Block a user