Private
Public Access
1
0

add stopwatches in PlantPositionRegistry

This commit is contained in:
2026-05-25 06:20:00 +02:00
parent 0f1bcece53
commit afdf3425b0

View File

@@ -22,6 +22,8 @@ public class PlantPositionRegistryModSystem2 : ModSystem, IPlantPositionRegistry
private static readonly Dictionary<int, ScanOffsetTable> offsetTables = [];
private readonly Stopwatch getCountsStopwatch = new();
private readonly Stopwatch getPlantsStopwatch = new();
private long? tickListenerId;
private readonly Dictionary<StructVec3i, BeehiveScanCursor> beehives = [];
private readonly HashSet<StructVec3i> flowerPositions = [];
@@ -97,6 +99,7 @@ public class PlantPositionRegistryModSystem2 : ModSystem, IPlantPositionRegistry
float RescanProgress
) GetPlantsNearPosition(BlockPos hivePos, int radius, List<StructVec3i> flowerPositionsBuffer, List<StructVec3i> 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);
}