diff --git a/OrekiWoofsBees.Common/PlantPositionRegistryModSystem2.cs b/OrekiWoofsBees.Common/PlantPositionRegistryModSystem2.cs index bb3fb2d..931e145 100644 --- a/OrekiWoofsBees.Common/PlantPositionRegistryModSystem2.cs +++ b/OrekiWoofsBees.Common/PlantPositionRegistryModSystem2.cs @@ -22,6 +22,8 @@ public class PlantPositionRegistryModSystem2 : ModSystem, IPlantPositionRegistry private static readonly Dictionary offsetTables = []; + private readonly Stopwatch getCountsStopwatch = new(); + private readonly Stopwatch getPlantsStopwatch = new(); private long? tickListenerId; private readonly Dictionary beehives = []; private readonly HashSet flowerPositions = []; @@ -97,6 +99,7 @@ public class PlantPositionRegistryModSystem2 : ModSystem, IPlantPositionRegistry float RescanProgress ) GetPlantsNearPosition(BlockPos hivePos, int radius, List flowerPositionsBuffer, List cropPositionsBuffer) { + getPlantsStopwatch.Restart(); flowerPositionsBuffer.Clear(); cropPositionsBuffer.Clear(); @@ -128,11 +131,13 @@ public class PlantPositionRegistryModSystem2 : ModSystem, IPlantPositionRegistry rescanProgress = cursor.GetRescanProgress(offsetTables); } + getPlantsStopwatch.StopAndLogTime(this, 0.1, $"radius: {radius}, in: {initialProgress}, re: {rescanProgress}, totals: {flowerPositions.Count}+{cropPositions.Count}"); return (initialProgress, rescanProgress); } public (int FlowerCount, int CropCount, float InitialScanProgress, float RescanProgress) GetPlantCountsNearPosition(BlockPos hivePos, int radius) { + getCountsStopwatch.Restart(); int flowers = 0; foreach (var flowerPos in flowerPositions) { @@ -160,6 +165,7 @@ public class PlantPositionRegistryModSystem2 : ModSystem, IPlantPositionRegistry rescanProgress = cursor.GetRescanProgress(offsetTables); } + getCountsStopwatch.StopAndLogTime(this, 0.1, $"radius: {radius}, fl: {flowers}, cr: {crops}, in: {initialProgress}, re: {rescanProgress}, totals: {flowerPositions.Count}+{cropPositions.Count}"); return (flowers, crops, initialProgress, rescanProgress); }