Class HotPathAttribute
- Namespace
- KeenEyes
- Assembly
- KeenEyes.Abstractions.dll
Marks a method as a hot path that runs frequently (e.g., every frame).
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
public sealed class HotPathAttribute : Attribute
- Inheritance
-
HotPathAttribute
- Inherited Members
Examples
public class GameSystem : SystemBase
{
public override void Update(float deltaTime)
{
// Automatically detected as hot path - no attribute needed
ProcessEntities(deltaTime);
}
[HotPath]
private void ProcessEntities(float deltaTime)
{
// Also analyzed as hot path due to attribute
foreach (var entity in World.Query<Position, Velocity>())
{
// LINQ would trigger warning here
}
}
}
Remarks
Methods marked with this attribute are analyzed for performance anti-patterns such as LINQ usage, allocations, and other operations that should be avoided in frequently-executed code paths.
The analyzer automatically treats the following as hot paths without requiring this attribute:
- Update(float) method overrides
OnBeforeUpdateandOnAfterUpdatemethod overrides
Use this attribute for custom methods that are called frequently but are not automatically recognized as hot paths.
Properties
Reason
Gets or sets a description of why this method is a hot path.
public string? Reason { get; set; }
Property Value
Examples
[HotPath(Reason = "Called every frame for each active particle")]
private void UpdateParticle(ref Particle particle, float deltaTime)
{
// ...
}
Remarks
Use this to document the expected call frequency or performance requirements for future maintainers.