add stopwatches in PlantPositionRegistry
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user