feat saving include npc position

This commit is contained in:
Bobby Rafael
2025-05-10 21:57:10 +07:00
parent 278e141ab9
commit d4699d6b36
5 changed files with 188 additions and 14 deletions

View File

@ -254,6 +254,9 @@ public class NPC : MonoBehaviour
// Pre-allocate visualizationSteps with estimated capacity to avoid reallocations
visualizationSteps = new List<PathfindingVisualizationStep>(4);
GC.Collect();
GC.WaitForPendingFinalizers(); // Tunggu semua finalizers selesai
// ===== MEMORY MEASUREMENT START: Ukur memory sebelum algoritma =====
long memoryBefore = System.GC.GetTotalMemory(false);
@ -281,6 +284,13 @@ public class NPC : MonoBehaviour
long memoryAfter = System.GC.GetTotalMemory(false);
long memoryUsed = memoryAfter - memoryBefore;
// float miliseconds = algorithmTimer.ElapsedMilliseconds;
//UnityEngine.Debug.Log("$algorithmTimer.ElapsedTicks: " + algorithmTimer.ElapsedTicks);
//UnityEngine.Debug.Log("$Stopwatch.Frequency: " + Stopwatch.Frequency);
//float seconds = (float)algorithmTimer.ElapsedTicks / Stopwatch.Frequency;
//UnityEngine.Debug.Log("$seconds: " + seconds);
float milliseconds = (algorithmTimer.ElapsedTicks * 1000.0f) / Stopwatch.Frequency;
// Calculate path length once and reuse
@ -327,7 +337,7 @@ public class NPC : MonoBehaviour
yield return null;
}
/// <summary>
/// Setup callbacks for tracking nodes in open/closed lists and visualization
/// </summary>