mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 12:03:04 +00:00
add stats about loading thread and pathfinding manager
This commit is contained in:
parent
831f52d76f
commit
30b9d56e36
3 changed files with 44 additions and 0 deletions
|
@ -66,6 +66,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
public BackgroundJobRunner BackgroundJobRunner { get; } = new BackgroundJobRunner();
|
||||
|
||||
[SerializeField] private ushort m_maxTimePerFrameMs = 0;
|
||||
public ushort MaxTimePerFrameMs => m_maxTimePerFrameMs;
|
||||
|
||||
private NodePathfindingData[][] m_nodePathfindingDatas = null;
|
||||
|
||||
|
|
|
@ -183,11 +183,36 @@ namespace SanAndreasUnity.Stats
|
|||
// on-screen messages
|
||||
sb.AppendFormat("num on-screen messages: {0}\n", OnScreenMessageManager.Instance.Messages.Count);
|
||||
sb.AppendFormat("num pooled on-screen messages: {0}\n", OnScreenMessageManager.Instance.NumPooledMessages);
|
||||
sb.AppendLine();
|
||||
|
||||
// loading thread
|
||||
sb.Append("loading thread:\n");
|
||||
sb.Append($"\tmax time per frame ms: {LoadingThread.Singleton.maxTimePerFrameMs}\n");
|
||||
AppendStatsForBackgroundJobRunner(sb, LoadingThread.Singleton.BackgroundJobRunner, "\t");
|
||||
sb.AppendLine();
|
||||
|
||||
// pathfinding manager
|
||||
sb.Append("pathfinding manager:\n");
|
||||
sb.Append($"\tmax time per frame ms: {PathfindingManager.Singleton.MaxTimePerFrameMs}\n");
|
||||
AppendStatsForBackgroundJobRunner(sb, PathfindingManager.Singleton.BackgroundJobRunner, "\t");
|
||||
sb.AppendLine();
|
||||
|
||||
|
||||
GUILayout.Label(sb.ToString());
|
||||
|
||||
}
|
||||
|
||||
private static void AppendStatsForBackgroundJobRunner(
|
||||
System.Text.StringBuilder sb,
|
||||
BackgroundJobRunner backgroundJobRunner,
|
||||
string prefix)
|
||||
{
|
||||
sb.Append($"{prefix}is background thread running: {backgroundJobRunner.IsBackgroundThreadRunning()}\n");
|
||||
sb.Append($"{prefix}background thread id: {backgroundJobRunner.GetBackgroundThreadId()}\n");
|
||||
sb.Append($"{prefix}num pending jobs: {backgroundJobRunner.GetNumPendingJobs()}\n");
|
||||
sb.Append($"{prefix}last processed job id: {backgroundJobRunner.GetLastProcessedJobId()}\n");
|
||||
sb.Append($"{prefix}processed jobs buffer count: {backgroundJobRunner.GetProcessedJobsBufferCount()}\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,24 @@ namespace SanAndreasUnity.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
public long GetLastProcessedJobId()
|
||||
{
|
||||
ThreadHelper.ThrowIfNotOnMainThread();
|
||||
return _lastProcessedJobId;
|
||||
}
|
||||
|
||||
public int? GetBackgroundThreadId()
|
||||
{
|
||||
ThreadHelper.ThrowIfNotOnMainThread();
|
||||
return _thread?.ManagedThreadId;
|
||||
}
|
||||
|
||||
public int GetProcessedJobsBufferCount()
|
||||
{
|
||||
ThreadHelper.ThrowIfNotOnMainThread();
|
||||
return _processedJobsBuffer.Count;
|
||||
}
|
||||
|
||||
public bool IsBackgroundThreadRunning()
|
||||
{
|
||||
ThreadHelper.ThrowIfNotOnMainThread();
|
||||
|
|
Loading…
Reference in a new issue