mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +01:00
Track element area update recursion count in UiMetrics
This commit is contained in:
parent
6a5e9a77ea
commit
fb3b586a35
3 changed files with 22 additions and 1 deletions
|
@ -32,6 +32,7 @@ Additions
|
||||||
Improvements
|
Improvements
|
||||||
- **Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn**
|
- **Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn**
|
||||||
- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum
|
- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum
|
||||||
|
- Track element area update recursion count in UiMetrics
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
|
- Fixed hidden scroll bars inhibiting scrolling on their parent panel
|
||||||
|
|
|
@ -832,6 +832,11 @@ namespace MLEM.Ui.Elements {
|
||||||
// we want to leave some leeway to prevent float rounding causing an infinite loop
|
// we want to leave some leeway to prevent float rounding causing an infinite loop
|
||||||
if (!autoSize.Equals(this.UnscrolledArea.Size, Element.Epsilon)) {
|
if (!autoSize.Equals(this.UnscrolledArea.Size, Element.Epsilon)) {
|
||||||
recursion++;
|
recursion++;
|
||||||
|
|
||||||
|
this.System.Metrics.SummedRecursionDepth++;
|
||||||
|
if (recursion > this.System.Metrics.MaxRecursionDepth)
|
||||||
|
this.System.Metrics.MaxRecursionDepth = recursion;
|
||||||
|
|
||||||
if (recursion >= 64)
|
if (recursion >= 64)
|
||||||
throw new ArithmeticException($"The area of {this} has recursively updated too often. Does its child {foundChild} contain any conflicting auto-sizing settings?");
|
throw new ArithmeticException($"The area of {this} has recursively updated too often. Does its child {foundChild} contain any conflicting auto-sizing settings?");
|
||||||
UpdateDisplayArea(autoSize);
|
UpdateDisplayArea(autoSize);
|
||||||
|
|
|
@ -29,6 +29,15 @@ namespace MLEM.Ui {
|
||||||
/// The amount of times that <see cref="Element.Update"/> was called.
|
/// The amount of times that <see cref="Element.Update"/> was called.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public uint Updates { get; internal set; }
|
public uint Updates { get; internal set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The total amount of recursions that <see cref="Element.ForceUpdateArea"/> went through.
|
||||||
|
/// Can be divided by <see cref="ForceAreaUpdates"/> to get an average.
|
||||||
|
/// </summary>
|
||||||
|
public uint SummedRecursionDepth { get; internal set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum recursion depth that <see cref="Element.ForceUpdateArea"/> went through in a single call.
|
||||||
|
/// </summary>
|
||||||
|
public int MaxRecursionDepth { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The amount of time that <see cref="Element.Draw(Microsoft.Xna.Framework.GameTime,Microsoft.Xna.Framework.Graphics.SpriteBatch,float,MLEM.Graphics.SpriteBatchContext)"/> took.
|
/// The amount of time that <see cref="Element.Draw(Microsoft.Xna.Framework.GameTime,Microsoft.Xna.Framework.Graphics.SpriteBatch,float,MLEM.Graphics.SpriteBatchContext)"/> took.
|
||||||
|
@ -49,6 +58,8 @@ namespace MLEM.Ui {
|
||||||
this.ForceAreaUpdates = 0;
|
this.ForceAreaUpdates = 0;
|
||||||
this.ActualAreaUpdates = 0;
|
this.ActualAreaUpdates = 0;
|
||||||
this.Updates = 0;
|
this.Updates = 0;
|
||||||
|
this.SummedRecursionDepth = 0;
|
||||||
|
this.MaxRecursionDepth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,7 +73,7 @@ namespace MLEM.Ui {
|
||||||
/// <summary>Returns the fully qualified type name of this instance.</summary>
|
/// <summary>Returns the fully qualified type name of this instance.</summary>
|
||||||
/// <returns>The fully qualified type name.</returns>
|
/// <returns>The fully qualified type name.</returns>
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return $"{nameof(this.ForceAreaUpdateTime)}: {this.ForceAreaUpdateTime}, {nameof(this.UpdateTime)}: {this.UpdateTime}, {nameof(this.ForceAreaUpdates)}: {this.ForceAreaUpdates}, {nameof(this.ActualAreaUpdates)}: {this.ActualAreaUpdates}, {nameof(this.Updates)}: {this.Updates}, {nameof(this.DrawTime)}: {this.DrawTime}, {nameof(this.Draws)}: {this.Draws}";
|
return $"{nameof(this.ForceAreaUpdateTime)}: {this.ForceAreaUpdateTime}, {nameof(this.UpdateTime)}: {this.UpdateTime}, {nameof(this.ForceAreaUpdates)}: {this.ForceAreaUpdates}, {nameof(this.ActualAreaUpdates)}: {this.ActualAreaUpdates}, {nameof(this.Updates)}: {this.Updates}, {nameof(this.SummedRecursionDepth)}: {this.SummedRecursionDepth}, {nameof(this.MaxRecursionDepth)}: {this.MaxRecursionDepth}, {nameof(this.DrawTime)}: {this.DrawTime}, {nameof(this.Draws)}: {this.Draws}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -78,6 +89,8 @@ namespace MLEM.Ui {
|
||||||
ForceAreaUpdates = left.ForceAreaUpdates + right.ForceAreaUpdates,
|
ForceAreaUpdates = left.ForceAreaUpdates + right.ForceAreaUpdates,
|
||||||
ActualAreaUpdates = left.ActualAreaUpdates + right.ActualAreaUpdates,
|
ActualAreaUpdates = left.ActualAreaUpdates + right.ActualAreaUpdates,
|
||||||
Updates = left.Updates + right.Updates,
|
Updates = left.Updates + right.Updates,
|
||||||
|
SummedRecursionDepth = left.SummedRecursionDepth + right.SummedRecursionDepth,
|
||||||
|
MaxRecursionDepth = left.MaxRecursionDepth + right.MaxRecursionDepth,
|
||||||
DrawTime = left.DrawTime + right.DrawTime,
|
DrawTime = left.DrawTime + right.DrawTime,
|
||||||
Draws = left.Draws + right.Draws
|
Draws = left.Draws + right.Draws
|
||||||
};
|
};
|
||||||
|
@ -96,6 +109,8 @@ namespace MLEM.Ui {
|
||||||
ForceAreaUpdates = left.ForceAreaUpdates - right.ForceAreaUpdates,
|
ForceAreaUpdates = left.ForceAreaUpdates - right.ForceAreaUpdates,
|
||||||
ActualAreaUpdates = left.ActualAreaUpdates - right.ActualAreaUpdates,
|
ActualAreaUpdates = left.ActualAreaUpdates - right.ActualAreaUpdates,
|
||||||
Updates = left.Updates - right.Updates,
|
Updates = left.Updates - right.Updates,
|
||||||
|
SummedRecursionDepth = left.SummedRecursionDepth - right.SummedRecursionDepth,
|
||||||
|
MaxRecursionDepth = left.MaxRecursionDepth - right.MaxRecursionDepth,
|
||||||
DrawTime = left.DrawTime - right.DrawTime,
|
DrawTime = left.DrawTime - right.DrawTime,
|
||||||
Draws = left.Draws - right.Draws
|
Draws = left.Draws - right.Draws
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue