WeakAuras

WeakAuras

200M Downloads

Coloring Spike for Profiling

Silvereyes1372 opened this issue ยท 8 comments

commented

Is your feature request related to a problem? Please describe.
From time to time, people ask on Discord to read their profiling, and a lot of white lines may be confusing. Usually, people answer by "remove everything with a spike greater than 2 or 3."

Describe the solution you'd like
A non-ChatGPT-generated code to color the spike based on the value, something like:
0 to 2 [green gradient to yellow]
2-3 [orange to red]
3+ [red]

Describe alternatives you've considered

Changing this function in profiling.lua

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
    local color
    if map.spike < 2 then
      color = string.format("|cff%02x%02x00", 255 * map.spike / 2, 255) 		 --smooth color gradient from green to yellow  for values 0 to 2
    elseif map.spike >= 2 and map.spike < 3 then
      color = string.format("|cffff%02x00", 255 * (map.spike - 2) / (3 - 2)) 	 --smooth color gradient from orange to red for values 2 to 3
    else 
      color = "|cffff0000" 														 -- Red for values 3 and above
    end

    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

Additional context
prof

commented

looks fine to me. you could be a "bit" smarter & highlight times that are statistical outliers rather than just ones that are above an arbitrary threshold, but that might not actually be smarter

since you already have the changes, feel free to open a pull request :)

commented

Oh, as a side note, linear interpolation through RGB color space can produce intermediate colors that look kind of muddy. Consider interpolating through HSV space instead:

function WeakAuras.GetHSVTransition(perc, r1, g1, b1, a1, r2, g2, b2, a2)

commented

Oh, as a side note, linear interpolation through RGB color space can produce intermediate colors that look kind of muddy. Consider interpolating through HSV space instead:

function WeakAuras.GetHSVTransition(perc, r1, g1, b1, a1, r2, g2, b2, a2)

Ok I dont really know what i'm doing , but after multiple trial and error I'v got this with chatgpt and it works, does it looks fine to you ?


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
    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

profile

commented

As for the pull request , I'm sorry i dont know how to do that.

commented

As for the pull request , I'm sorry i dont know how to do that.

https://docs.github.com/articles/creating-a-pull-request explains how to do it

basically, clone repository to your account, make the change on your repository, then github let you open a pull request

commented

I've downloaded an app (GitHub Desktop). I think I've cloned the main branch or something. I made the changes, but now where should I click?

I tried "Repository > Pull," but it doesn't work. Should I click on "Commit to main"?

Pull request

commented

I don't use the app and can't tell what to click, but as i said you have to clone/fork to your own account, edit your own clone, then make PR

commented

k I'll check. ty