Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Darling/Darling.Tests/Viewer4571Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using PerformanceMonitor.PlanAnalysis;
using Xunit;

namespace Darling.Tests;

/// <summary>
/// Pins the Wait Stats card header's tooltip (#4571), matching erikdarlingdata/PerformanceStudio's
/// desktop viewer: null when there are no waits, otherwise the total wait time and wait-type count.
/// </summary>
public class Viewer4571Tests
{
[Fact]
public void WaitStatsHeaderTooltip_NoWaits_IsNull()
{
Assert.Null(PlanDisplayText.WaitStatsHeaderTooltip(0, 0));
}

[Fact]
public void WaitStatsHeaderTooltip_WithWaits_DescribesCountAndTotal()
{
Assert.Equal("1,234 ms of waits across 3 wait types", PlanDisplayText.WaitStatsHeaderTooltip(3, 1234));
}
}
7 changes: 7 additions & 0 deletions PerformanceMonitor.PlanAnalysis/PlanDisplayText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public static class PlanDisplayText
public static string? ParseErrorMessage(ParsedPlan plan) =>
plan.ParseError == null ? null : $"This plan couldn't be parsed: {plan.ParseError}";

/// <summary>
/// The Wait Stats card's header tooltip, matching erikdarlingdata/PerformanceStudio's desktop viewer:
/// shown only when there are waits to describe.
/// </summary>
public static string? WaitStatsHeaderTooltip(int waitCount, long totalWaitMs) =>
waitCount > 0 ? $"{totalWaitMs:N0} ms of waits across {waitCount} wait types" : null;

/// <summary>
/// The CPU:Elapsed ratio shown in the runtime summary, matching
/// erikdarlingdata/PerformanceStudio@28d4c74's row: CPU time with external-wait time
Expand Down
2 changes: 2 additions & 0 deletions PerformanceMonitor.Ui/PlanViewerControl.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ private void ShowWaitStats(List<WaitStatInfo> waits, bool isActualPlan)
if (waits.Count == 0)
{
WaitStatsHeader.Text = "Wait Stats";
WaitStatsHeader.ToolTip = PlanDisplayText.WaitStatsHeaderTooltip(0, 0);
WaitStatsEmpty.Text = isActualPlan
? "No wait stats recorded"
: "No wait stats (estimated plan)";
Expand All @@ -1081,6 +1082,7 @@ private void ShowWaitStats(List<WaitStatInfo> waits, bool isActualPlan)
var totalWait = sorted.Sum(w => w.WaitTimeMs);

WaitStatsHeader.Text = $" Wait Stats \u2014 {totalWait:N0}ms total";
WaitStatsHeader.ToolTip = PlanDisplayText.WaitStatsHeaderTooltip(sorted.Count, totalWait);

var longestName = sorted.Max(w => w.WaitType.Length);
var nameColWidth = longestName * 6.5 + 10;
Expand Down
Loading