Skip to content

Commit 539c28f

Browse files
feat: Improving heatmap ( Fixes PoshWeb#13 )
Ensuring fastest is most green
1 parent 5e830e4 commit 539c28f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

build.ps1

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,27 @@ $([Web.HttpUtility]::HtmlAttributeEncode($descriptionMessage))
164164
Select-Object -ExpandProperty Html
165165
"</h4>"
166166

167+
# Make a really basic heatmap (yes, this is that easy)
168+
# We want the fastest item to be the most green, so start by getting its relative speed
169+
$fastestRelativeSpeed = $buildTimes[0].RelativeSpeed
167170
foreach ($buildTime in $buildTimes) {
171+
# We only neeed two colors for the heatmap: green and red.
172+
# Green is calculated by:
168173
$green = [byte][Math]::Floor(
169-
(1 - $buildTime.RelativeSpeed) * 255
174+
# Starting at one
175+
(1 -
176+
# Subtracting the relative speed
177+
$buildTime.RelativeSpeed +
178+
# and adding the fastest relative speed.
179+
$fastestRelativeSpeed
180+
) * 255 # (multiply by 255 and floor it to make a byte)
170181
)
182+
# Red is even easier, it's just the relative speed as a byte
171183
$red = [byte][Math]::Floor(
172184
$buildTime.RelativeSpeed * 255
173185
)
186+
187+
# Use a bit of C# string formatting to make a color (blue is always blank)
174188
$color = "#{0:x2}{1:x2}00" -f $red, $green
175189

176190
"<details open>"

0 commit comments

Comments
 (0)