Skip to content

Commit 5bc779f

Browse files
rogeralsingclaude
andcommitted
Add heat color gradient to timeline bars
Timeline bars now colored based on duration percentage: - 100% = red, ~50% = orange, ≤5% = green 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 66bad0d commit 5bc779f

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/ProfileTool/Program.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,47 @@ string RenderTimelineBar(CallTreeNode node, TimelineContext ctx)
27152715
};
27162716
}
27172717

2718-
return $"[cyan]{new string(buffer)}[/]";
2718+
// Color based on percentage: 5% = green, 50% = yellow/orange, 100% = red
2719+
var pct = durationRatio * 100;
2720+
var color = GetHeatColor(pct);
2721+
2722+
return $"[{color}]{new string(buffer)}[/]";
2723+
}
2724+
2725+
string GetHeatColor(double percentage)
2726+
{
2727+
// Clamp percentage to 0-100
2728+
percentage = Math.Clamp(percentage, 0, 100);
2729+
2730+
int r, g, b;
2731+
2732+
if (percentage <= 5)
2733+
{
2734+
// 0-5%: Pure green
2735+
r = 0;
2736+
g = 200;
2737+
b = 0;
2738+
}
2739+
else if (percentage <= 50)
2740+
{
2741+
// 5-50%: Green to Yellow/Orange
2742+
// Interpolate from green (0,200,0) to orange (255,165,0)
2743+
var t = (percentage - 5) / 45.0;
2744+
r = (int)(0 + t * 255);
2745+
g = (int)(200 - t * 35); // 200 -> 165
2746+
b = 0;
2747+
}
2748+
else
2749+
{
2750+
// 50-100%: Orange to Red
2751+
// Interpolate from orange (255,165,0) to red (255,0,0)
2752+
var t = (percentage - 50) / 50.0;
2753+
r = 255;
2754+
g = (int)(165 - t * 165); // 165 -> 0
2755+
b = 0;
2756+
}
2757+
2758+
return $"rgb({r},{g},{b})";
27192759
}
27202760

27212761
char SelectLeftBlock(double fraction)

0 commit comments

Comments
 (0)