Scott
Scott

Reputation: 5263

Simple math/programming question. Individual percentage from total

I'm no good at math. :) Is this right?

I'm accumulating all CPU seconds, and I need to find what percentage the addon's CPU time is from the total.

function PluginResources.GetTotalCPU(addon)
    UpdateAddOnCPUUsage()
    local totalCPU = 0
    for i=1, GetNumAddOns() do
        totalCPU = totalCPU + (GetAddOnCPUUsage(i) )
    end 
    local addonUsage = GetAddOnCPUUsage(addon)
    local usage = totalCPU / addonUsage
    return usage
end

Upvotes: 0

Views: 589

Answers (1)

lhf
lhf

Reputation: 72332

Try usage = addonUsage / totalCPU.

Upvotes: 2

Related Questions