perf(fill): avoid redundant bounds recomputation

This commit is contained in:
aj
2026-09-25 21:45:03 -04:00
parent 4ec92c95ec
commit 4553f8afad
10 changed files with 483 additions and 12 deletions
+1
View File
@@ -206,6 +206,7 @@ namespace OpenNest
/// </summary>
public void UpdateBounds()
{
PerfCounters.CountPartBoundsUpdate();
BoundingBox = Program.BoundingBox();
BoundingBox.Offset(Location);
}
+6
View File
@@ -14,12 +14,14 @@ namespace OpenNest
private static long partIntersects;
private static long fillScoreComputations;
private static long partBoundaryPreparations;
private static long partBoundsUpdates;
public static long FindBestFits => Interlocked.Read(ref findBestFits);
public static long OffsetPerimeterEntities => Interlocked.Read(ref offsetPerimeterEntities);
public static long PartIntersects => Interlocked.Read(ref partIntersects);
public static long FillScoreComputations => Interlocked.Read(ref fillScoreComputations);
public static long PartBoundaryPreparations => Interlocked.Read(ref partBoundaryPreparations);
public static long PartBoundsUpdates => Interlocked.Read(ref partBoundsUpdates);
[Conditional("DEBUG")]
public static void CountFindBestFits() => Interlocked.Increment(ref findBestFits);
@@ -37,6 +39,9 @@ namespace OpenNest
[Conditional("DEBUG")]
public static void CountPartBoundaryPreparation() => Interlocked.Increment(ref partBoundaryPreparations);
[Conditional("DEBUG")]
public static void CountPartBoundsUpdate() => Interlocked.Increment(ref partBoundsUpdates);
public static void Reset()
{
Interlocked.Exchange(ref findBestFits, 0);
@@ -44,6 +49,7 @@ namespace OpenNest
Interlocked.Exchange(ref partIntersects, 0);
Interlocked.Exchange(ref fillScoreComputations, 0);
Interlocked.Exchange(ref partBoundaryPreparations, 0);
Interlocked.Exchange(ref partBoundsUpdates, 0);
}
}
}