From 076193caa23332eba6cc76d11c2b7ef293f4ab53 Mon Sep 17 00:00:00 2001 From: Silvereyes1372 Date: Thu, 1 Feb 2024 15:31:58 +0100 Subject: [PATCH 1/4] Update Profiling.lua Coloring Spike for Profiling --- WeakAuras/Profiling.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/WeakAuras/Profiling.lua b/WeakAuras/Profiling.lua index 027d10eef0..45744a0d22 100644 --- a/WeakAuras/Profiling.lua +++ b/WeakAuras/Profiling.lua @@ -316,14 +316,32 @@ local function PrintOneProfile(popup, name, map, total) if map.count ~= 0 then popup:AddText(name .. " ERROR: count is not zero:" .. " " .. map.count) end + local percent = "" if total then percent = ", " .. string.format("%.2f", 100 * map.elapsed / total) .. "%" end + local spikeInfo = "" + if map.spike then - spikeInfo = string.format("(%.2fms)", map.spike) + local color + local r, g, b, a + + if map.spike < 2 then + r, g, b, a = WeakAuras.GetHSVTransition(map.spike / 2, 0, 1, 0, 1, 1, 1, 0, 1) + elseif map.spike >= 2 and map.spike < 3 then + r, g, b, a = WeakAuras.GetHSVTransition((map.spike - 2) , 1, 1, 0, 1, 1, 0.65, 0, 1) + else + r, g, b, a = WeakAuras.GetHSVTransition(1, 1, 0, 0, 1, 1, 0, 0, 1) + end + + color = string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255) + spikeInfo = string.format("%s(%.2fms)|r", color, map.spike) + else + spikeInfo = "" -- handle no map.spike end + popup:AddText(string.format("%s |cff999999%.2fms%s %s|r", name, map.elapsed, percent, spikeInfo)) end From cee7f1dbb6a6f06cb4c7e10306f0e2bfd8592fa4 Mon Sep 17 00:00:00 2001 From: Silvereyes1372 Date: Thu, 1 Feb 2024 16:29:35 +0100 Subject: [PATCH 2/4] Update Profiling.lua --- WeakAuras/Profiling.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/WeakAuras/Profiling.lua b/WeakAuras/Profiling.lua index 45744a0d22..55ebb613a0 100644 --- a/WeakAuras/Profiling.lua +++ b/WeakAuras/Profiling.lua @@ -323,27 +323,26 @@ local function PrintOneProfile(popup, name, map, total) end local spikeInfo = "" - if map.spike then local color local r, g, b, a if map.spike < 2 then r, g, b, a = WeakAuras.GetHSVTransition(map.spike / 2, 0, 1, 0, 1, 1, 1, 0, 1) - elseif map.spike >= 2 and map.spike < 3 then - r, g, b, a = WeakAuras.GetHSVTransition((map.spike - 2) , 1, 1, 0, 1, 1, 0.65, 0, 1) - else - r, g, b, a = WeakAuras.GetHSVTransition(1, 1, 0, 0, 1, 1, 0, 0, 1) + elseif map.spike >= 2 and map.spike < 2.5 then + r, g, b, a = WeakAuras.GetHSVTransition((map.spike - 2) * 2, 1, 1, 0, 1, 1, 0.65, 0, 1) + elseif map.spike >= 2.5 and map.spike < 3 then + r, g, b, a = WeakAuras.GetHSVTransition((map.spike - 2.5) * 2, 1, 0.65, 0, 1, 1, 0, 0, 1) + else + r, g, b, a = 1, 0, 0, 1 end - color = string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255) + local color = string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255) spikeInfo = string.format("%s(%.2fms)|r", color, map.spike) - else - spikeInfo = "" -- handle no map.spike end popup:AddText(string.format("%s |cff999999%.2fms%s %s|r", name, map.elapsed, percent, spikeInfo)) -end +end local function SortProfileMap(map) local result = {} From a9900ca74495b4040e2a7f4191f358ae313fa5ea Mon Sep 17 00:00:00 2001 From: Buds Date: Sun, 4 Feb 2024 11:58:18 +0100 Subject: [PATCH 3/4] code cleanup --- WeakAuras/Profiling.lua | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/WeakAuras/Profiling.lua b/WeakAuras/Profiling.lua index 55ebb613a0..d68477ea42 100644 --- a/WeakAuras/Profiling.lua +++ b/WeakAuras/Profiling.lua @@ -319,30 +319,26 @@ local function PrintOneProfile(popup, name, map, total) local percent = "" if total then - percent = ", " .. string.format("%.2f", 100 * map.elapsed / total) .. "%" + percent = (", %.2f%%"):format(100 * map.elapsed / total) end local spikeInfo = "" if map.spike then - local color - local r, g, b, a - + local r, g, b if map.spike < 2 then - r, g, b, a = WeakAuras.GetHSVTransition(map.spike / 2, 0, 1, 0, 1, 1, 1, 0, 1) - elseif map.spike >= 2 and map.spike < 2.5 then - r, g, b, a = WeakAuras.GetHSVTransition((map.spike - 2) * 2, 1, 1, 0, 1, 1, 0.65, 0, 1) - elseif map.spike >= 2.5 and map.spike < 3 then - r, g, b, a = WeakAuras.GetHSVTransition((map.spike - 2.5) * 2, 1, 0.65, 0, 1, 1, 0, 0, 1) + r, g, b = WeakAuras.GetHSVTransition(map.spike / 2, 0, 1, 0, 1, 1, 1, 0, 1) + elseif map.spike < 2.5 then + r, g, b = WeakAuras.GetHSVTransition((map.spike - 2) * 2, 1, 1, 0, 1, 1, 0.65, 0, 1) + elseif map.spike < 3 then + r, g, b = WeakAuras.GetHSVTransition((map.spike - 2.5) * 2, 1, 0.65, 0, 1, 1, 0, 0, 1) else - r, g, b, a = 1, 0, 0, 1 + r, g, b = 1, 0, 0 end - - local color = string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255) - spikeInfo = string.format("%s(%.2fms)|r", color, map.spike) + spikeInfo = ("|cff%02x%02x%02x(%.2fms)|r"):format(r * 255, g * 255, b * 255, map.spike) end - popup:AddText(string.format("%s |cff999999%.2fms%s %s|r", name, map.elapsed, percent, spikeInfo)) -end + popup:AddText(("%s |cff999999%.2fms%s %s|r"):format(name, map.elapsed, percent, spikeInfo)) +end local function SortProfileMap(map) local result = {} From c91552188e7bfd1ce1ac5f01db8d69f156dc44ae Mon Sep 17 00:00:00 2001 From: Infus Date: Sun, 4 Feb 2024 16:35:43 +0100 Subject: [PATCH 4/4] Also sort by spike data --- WeakAuras/Profiling.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WeakAuras/Profiling.lua b/WeakAuras/Profiling.lua index d68477ea42..9f3bac7114 100644 --- a/WeakAuras/Profiling.lua +++ b/WeakAuras/Profiling.lua @@ -347,6 +347,9 @@ local function SortProfileMap(map) end sort(result, function(a, b) + if map[a].spike and map[b].spike then + return map[a].spike > map[b].spike + end return map[a].elapsed > map[b].elapsed end)