mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
Merge branch 'dev' of github.com:DCFApixels/DragonECS into dev
This commit is contained in:
commit
0697702122
@ -13,7 +13,10 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public readonly int id;
|
public readonly int id;
|
||||||
internal EcsProfilerMarker(int id) { this.id = id; }
|
internal EcsProfilerMarker(int id) { this.id = id; }
|
||||||
public EcsProfilerMarker(string name) { id = DebugService.Instance.RegisterMark(name); }
|
public EcsProfilerMarker(string name)
|
||||||
|
{
|
||||||
|
id = DebugService.Instance.RegisterMark(name);
|
||||||
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Begin() { DebugService.Instance.ProfilerMarkBegin(id); }
|
public void Begin() { DebugService.Instance.ProfilerMarkBegin(id); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -157,6 +160,7 @@ namespace DCFApixels.DragonECS
|
|||||||
Name = name;
|
Name = name;
|
||||||
ID = iD;
|
ID = iD;
|
||||||
}
|
}
|
||||||
|
public override string ToString() { return this.AutoToString(); }
|
||||||
}
|
}
|
||||||
public IEnumerable<MarkerInfo> MarkerInfos
|
public IEnumerable<MarkerInfo> MarkerInfos
|
||||||
{
|
{
|
||||||
@ -181,14 +185,15 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
var oldService = _instance;
|
var oldService = _instance;
|
||||||
_instance = service;
|
_instance = service;
|
||||||
|
if(_instance != null)
|
||||||
|
{ //TODO Так, всеже треды влияют друг на друга, скоерее всего проблема в использовании _nameIdTable/ Так вроде пофиксил, но не понял как конкретно
|
||||||
foreach (var info in oldService.MarkerInfos)
|
foreach (var info in oldService.MarkerInfos)
|
||||||
{
|
{
|
||||||
service._idDispenser.Use(info.ID);
|
service._idDispenser.Use(info.ID);
|
||||||
service._nameIdTable.TryAdd(info.Name, info.ID);
|
service._nameIdTable.TryAdd(info.Name, info.ID);
|
||||||
service.OnNewProfilerMark(info.ID, info.Name);
|
service.OnNewProfilerMark(info.ID, info.Name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
service.OnServiceSetup(oldService);
|
service.OnServiceSetup(oldService);
|
||||||
OnServiceChanged(service);
|
OnServiceChanged(service);
|
||||||
}
|
}
|
||||||
@ -199,7 +204,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static Action<DebugService> OnServiceChanged = delegate { };
|
public static Action<DebugService> OnServiceChanged = delegate { };
|
||||||
|
|
||||||
private IdDispenser _idDispenser = new IdDispenser(16, 0);
|
private IdDispenser _idDispenser = new IdDispenser(16, 0);
|
||||||
private ConcurrentDictionary<string, int> _nameIdTable = new ConcurrentDictionary<string, int>();
|
private Dictionary<string, int> _nameIdTable = new Dictionary<string, int>();
|
||||||
public abstract void Print(string tag, object v);
|
public abstract void Print(string tag, object v);
|
||||||
public abstract void Break();
|
public abstract void Break();
|
||||||
public int RegisterMark(string name)
|
public int RegisterMark(string name)
|
||||||
@ -208,12 +213,15 @@ namespace DCFApixels.DragonECS
|
|||||||
if (!_nameIdTable.TryGetValue(name, out id))
|
if (!_nameIdTable.TryGetValue(name, out id))
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
|
{
|
||||||
|
if (!_nameIdTable.TryGetValue(name, out id))
|
||||||
{
|
{
|
||||||
id = _idDispenser.UseFree();
|
id = _idDispenser.UseFree();
|
||||||
_nameIdTable.TryAdd(name, id);
|
_nameIdTable.Add(name, id);
|
||||||
}
|
|
||||||
}
|
|
||||||
OnNewProfilerMark(id, name);
|
OnNewProfilerMark(id, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
public void DeleteMark(string name)
|
public void DeleteMark(string name)
|
||||||
@ -221,8 +229,7 @@ namespace DCFApixels.DragonECS
|
|||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
int id = _nameIdTable[name];
|
int id = _nameIdTable[name];
|
||||||
//TODO проверить TryRemove
|
_nameIdTable.Remove(name);
|
||||||
_nameIdTable.TryRemove(name, out id);
|
|
||||||
_idDispenser.Release(id);
|
_idDispenser.Release(id);
|
||||||
OnDelProfilerMark(id);
|
OnDelProfilerMark(id);
|
||||||
}
|
}
|
||||||
@ -277,6 +284,10 @@ namespace DCFApixels.DragonECS
|
|||||||
Name = name;
|
Name = name;
|
||||||
ID = id;
|
ID = id;
|
||||||
}
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return this.AutoToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private MarkerData[] _stopwatchs;
|
private MarkerData[] _stopwatchs;
|
||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
@ -332,10 +343,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
var color = Console.ForegroundColor;
|
var color = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
_stopwatchs[id].stopwatch.Start();
|
_stopwatchs[id].Stopwatch.Start();
|
||||||
|
|
||||||
Console.Write(PROFILER_MARKER_CACHE);
|
Console.Write(PROFILER_MARKER_CACHE);
|
||||||
Console.Write(_stopwatchs[id].name);
|
Console.Write(_stopwatchs[id].Name);
|
||||||
Console.WriteLine("> ");
|
Console.WriteLine("> ");
|
||||||
|
|
||||||
Console.ForegroundColor = color;
|
Console.ForegroundColor = color;
|
||||||
@ -346,13 +357,13 @@ namespace DCFApixels.DragonECS
|
|||||||
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER) && !UNITY_5_3_OR_NEWER
|
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER) && !UNITY_5_3_OR_NEWER
|
||||||
var color = Console.ForegroundColor;
|
var color = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
_stopwatchs[id].stopwatch.Stop();
|
_stopwatchs[id].Stopwatch.Stop();
|
||||||
var time = _stopwatchs[id].stopwatch.Elapsed;
|
var time = _stopwatchs[id].Stopwatch.Elapsed;
|
||||||
_stopwatchs[id].stopwatch.Reset();
|
_stopwatchs[id].Stopwatch.Reset();
|
||||||
|
|
||||||
Console.Write(PROFILER_MARKER_CACHE);
|
Console.Write(PROFILER_MARKER_CACHE);
|
||||||
Console.Write("> ");
|
Console.Write("> ");
|
||||||
Console.Write(_stopwatchs[id].name);
|
Console.Write(_stopwatchs[id].Name);
|
||||||
Console.Write(" s:");
|
Console.Write(" s:");
|
||||||
|
|
||||||
int written = 0;
|
int written = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user