You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance performance regression tests with updated targets and optimizations
This commit updates the performance regression tests to reflect more realistic targets based on recent performance improvements. Key changes include:
- Increased target for quantity creation from >1M to >2.8M ops/sec.
- Updated unit conversion target from >500K to >9M ops/sec.
- Adjusted arithmetic operations target from >2M to >2.5M ops/sec.
- Enhanced physics relationship calculations target from >200K to >2.2M ops/sec.
- Revised constant access target from >5M to >50M ops/sec.
- Improved cross-domain calculations target from >50K to >1M ops/sec.
Additionally, optimizations were made to pre-create objects outside measurement loops to minimize allocation overhead, ensuring more accurate performance assessments. These changes aim to enhance the reliability and effectiveness of the performance regression testing suite.
Copy file name to clipboardExpand all lines: .cursor/rules/derived-cursor-rules.mdc
+26-2Lines changed: 26 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ When adding XML documentation comments:
83
83
* **Physical Constants First**: Identify all mechanical constants needed (e.g., gravitational acceleration, standard atmospheric pressure, Planck’s constant if needed for mechanics, etc.). Add them to `PhysicalConstants.cs` under appropriate categories (Fundamental, Mechanical, etc.). Use the `PhysicalConstants.Generic` pattern for type-safe access. Include XML docs and source references (CODATA, NIST, etc.).
84
84
* **Define Quantities**:
85
85
* Location: `Quantities/Mechanics/`
86
-
* Quantities to Implement: Force (`Force.cs`), Pressure (`Pressure.cs`), Energy (`Energy.cs`), Power (`Power.cs`), Torque (`Torque.cs`), Momentum (`Momentum.cs`), AngularVelocity (`AngularVelocity.cs`), AngularAcceleration (`AngularAcceleration.cs`), MomentOfInertia (`MomentOfInertia.cs`), Density (`Density.cs`), SpecificGravity (`SpecificGravity.cs`), and any others listed in your TODOs. Follow the template from the Chemical domain (generic, type-safe, XML docs, unit conversions, etc.).
86
+
* Quantities to Implement: Force (`Force.cs`), Pressure (`Pressure.cs`), Energy (`Energy.cs`), Power (`Power.cs`), Torque (`Torque.cs`), Momentum (`Momentum.cs`), AngularVelocity (`AngularAcceleration.cs`), AngularAcceleration (`AngularAcceleration.cs`), MomentOfInertia (`MomentOfInertia.cs`), Density (`Density.cs`), SpecificGravity (`SpecificGravity.cs`), and any others listed in your TODOs. Follow the template from the Chemical domain (generic, type-safe, XML docs, unit conversions, etc.).
87
87
* **Units and Dimensions**: For each quantity, define the SI and common units in `Units.cs`. Add or update `PhysicalDimensions.cs` as needed for new dimensions (e.g., force, energy).
88
88
* **Mathematical Relationships**: Implement relationships (e.g., F = m·a, P = F/A, E = F·d) as static methods or extension methods. Add unit tests to verify these relationships using both constants and calculated values.
89
89
* **Testing**: For each quantity: Create unit tests for creation, conversion, and validation. Add mathematical verification tests (e.g., compare calculated force to expected value). Add edge case and error handling tests.
@@ -255,4 +255,28 @@ When adding XML documentation comments:
255
255
* **Performance Benchmarks Garbage Collection:** In performance benchmarks, force garbage collection before measuring final memory usage by calling `GC.Collect()` and `GC.WaitForPendingFinalizers()` before `GC.GetTotalMemory()`.
256
256
* **Performance Benchmarks Memory Measurement:** In performance benchmarks, use `GC.GetTotalMemory(true)` to get the total memory allocated, including memory that is waiting to be collected.
257
257
* **Performance Benchmarks Removal:** Remove the `BenchmarkMemoryAllocation` test as it is incompatible with our testing setup.
258
-
* **Test Execution:** Don't use `-m:1` when executing tests.
258
+
* **Test Execution:** Don't use `-m:1` when executing tests.
259
+
* **Performance Regression Analysis:** When a performance regression test fails, examine the failing test and related code (including base classes) to identify potential causes.
260
+
* **Performance Regression Test Optimization:** For performance regression tests that measure arithmetic operations, pre-create objects outside the measurement loop to eliminate object allocation overhead and ensure accurate measurement of pure arithmetic performance.
261
+
* **Performance Regression Test Setup**: Check all performance regression tests to ensure their setup is correct and accurately measures the intended performance characteristic.
262
+
* **Performance Regression Test Optimization - Object Reuse**: In performance regression tests, pre-create objects outside the measurement loop to reuse them, updating their values instead of creating new objects in each iteration. This eliminates object allocation overhead and ensures accurate measurement of the intended performance characteristic.
263
+
* **Performance Regression Test Targets**: Adjust performance regression test targets to be appropriate for the expected performance after optimizations.
264
+
* **Performance Regression Test Optimization - Object Reuse**: In performance regression tests, pre-create objects outside the measurement loop to reuse them, updating their values instead of creating new objects in each iteration.
265
+
* **Performance Regression Test Investigation**: Investigate why any particular domains or types have lower performance.
266
+
* **Performance Regression Test Optimization - Object Pre-Creation**: In performance regression tests, pre-create objects outside the measurement loop to reuse them, updating their values instead of creating new objects in each iteration. This eliminates object allocation overhead and ensures accurate measurement of the intended performance characteristic.
267
+
* **Performance Regression Test Targets**: Adjust performance regression test targets to be appropriate for the expected performance after optimizations. Targets should be realistic based on achieved performance, while still providing a reasonable buffer for variations across different systems.
268
+
269
+
**Updated Performance Targets - Final Results**
270
+
271
+
All 6 performance baseline tests now have **realistic targets** based on actual performance capabilities:
0 commit comments