Download
(171Kb)
Download
Updated: 05-17-06 04:45 AM
Pictures
File Info
Updated:05-17-06 04:45 AM
Created:unknown
Downloads:4,104
Favorites:23
MD5:

LuaProfiler

Version: 1.5.0.0
by: Shag [More]

allows to trace functions calls and prints how much time was spent there on average and peak and how much time (in %) was spent in the function.

Usage:

To open the window use this slash command: /profiler

The left editbox is for the scope pattern (leave empty if you want to trace global functions), the right editbox is for the function pattern. Enter the patterns and press 'Add', depending on how much functions this addon has to hook it may take some time.
The frame isn't updated automatically, press one of the column headers to refresh the view. You can sort the data by all the columns, just press the column header.
Press 'Reset' to reset all trace data (does not unhook, only resets statistics)
Press 'Clear' to unhook all functions, and 'Ok' to close the window.

If you press one of the trace-lines it prints a summary to the chatframe, hold SHIFT while clicking the line to unhook the function, press CONTROL while clicking the line to reset the trace data for one particular function.


NOTE: If you are playing under linux (under wine, not confirmed under cedega), edit LuaProfiler.lua and at the very top of the file set 'LINUX_HACK' to 1000000 (number, 1 million).

NOTE: If you are playing under Widows, make sure hat LINUX_HACK is '1' (number, one), I often forget to change it before I make the release.


EXAMPLES:

To trace blizzards OnUpdate functions set the function pattern to "_OnUpdate"

If you have an addon that was designed in an OO way, add the 'class' name to the scope input field, I trace coolDown by setting the scope field to 'coolDown'. You also can trace LuaProfiler itself, set the scope to 'LuaProfiler'



Column Labels

Each label has four letters, the first incidates the type ('C' == Calls, 'T' == Time, 'M' == Memory, 'G' == Garbage Collection), the second and third how the data was gathered ('pC' = per Call, 'pS' == per Second, 'sR' == since (last) Reset) and the fourth the sub-types ('H'/'A'/'L' = High/Average/Low).

examples:
CsRC = Calls since (last) Reset (the last 'C' means nothing, yet )
TpCA = Time per Call Average - Average time per call spend in the functions
MpCH = Memory per Call High - the highest amount of memory allocated by one call.
GsRC = Garbage collections since (last) Reset


DUMP
by pressing the 'Dump' button, all stats for functions taht have been executed at least once are dumped into the SavedVariables file. I recommend a lua-script for analyzing the data. Here is a stub:

Code:
dofile("LuaProfiler.lua")
for dumpIndex, dumpTable in LuaProfilerDumps do
    print("Inspecting dump #"..dumpIndex)
    for _, traceInfo in dumpTable do
        print("Function \""..traceInfo.functionName.."\" has been executed "..traceInfo.stat["CsRC"].." times")
    end
end

CREDITS

credits go to 'Gello', he has created the beautiful addon OnEventWatch and everything I've done is based on that.



ChangeLog

1.5.0.0
- added 'Dump' button to dump the stats to the SavedVariables.

1.4.0.0
- reworked interface
- much more statictical data shown

1.3.0.0
- now also displaying:
~ memory usage (in kbytes)
~ how many times the GC was triggered.

1.2.0.0
- fixed typo in function argument list

1.1.0.0
- now shows usage for all traced function right of the input fields

Optional Files (0)


Post A Reply Comment Options
Unread 04-20-06, 09:51 PM  
Maia
A Deviate Faerie Dragon
AddOn Author - Click to view AddOns

Forum posts: 15
File comments: 6
Uploads: 4
I'm impressed. Is there a way to see which functions trigger garbage collections, or how much avg memory increase per sec is caused by and function?
Report comment to moderator  
Reply With Quote
Unread 04-21-06, 09:12 AM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
official discussion thread

Report comment to moderator  
Reply With Quote
Unread 04-22-06, 03:53 AM  
Parintele
A Kobold Labourer

Forum posts: 1
File comments: 1
Uploads: 0
Great mod! Helped me identify some big resource hoggers, like ABInfo.

As a note, seems like Wine and Cedega do things slightly different, because I'm playing WoW on Cedega, and LINUX_HACK needs to be 1 in this case.
Report comment to moderator  
Reply With Quote
Unread 04-22-06, 07:32 AM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
Originally posted by Parintele
As a note, seems like Wine and Cedega do things slightly different, because I'm playing WoW on Cedega, and LINUX_HACK needs to be 1 in this case.
I should rename it to WINE_HACK then
Report comment to moderator  
Reply With Quote
Unread 04-22-06, 11:39 AM  
Rae
A Kobold Labourer

Forum posts: 0
File comments: 2
Uploads: 0
im unclear of hw to use it. So if i wanna check my Tittan. i type Tittan in the scope box?
Report comment to moderator  
Reply With Quote
Unread 04-22-06, 01:46 PM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
Originally posted by Rae im unclear of hw to use it. So if i wanna check my Tittan. i type Tittan in the scope box?
There is an official thread, post your question there !
Report comment to moderator  
Reply With Quote
Unread 04-28-06, 06:36 PM  
Shark
A Defias Bandit

Forum posts: 3
File comments: 56
Uploads: 0
If I add a function to the profile window, why does the count go to 1 instead of 0? after calling this function once, count goes up to 2 and peak time is double of avg time (but should be the same).
Last edited by Shark : 04-28-06 at 06:36 PM.
Report comment to moderator  
Reply With Quote
Unread 04-30-06, 04:37 PM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
Originally posted by Shark
If I add a function to the profile window, why does the count go to 1 instead of 0? after calling this function once, count goes up to 2 and peak time is double of avg time (but should be the same).
because that prevents a 'division by zero'. The more often a function is called the more accurate the data are.
Report comment to moderator  
Reply With Quote
Unread 05-04-06, 07:10 PM  
Tinkerboom
A Kobold Labourer

Forum posts: 0
File comments: 4
Uploads: 0
This is brilliant! I'm a coder (on linux) and found 2 memory leaks (that's been bothering me for ages) in about 5 minutes.

But could you post some descriptions of the different colums? Some are pretty easy to figure out, but what does for example usage mean? Total time used by that function?


I know a few of my mods are slowing me down a lot, but I haven't been able to figure out exactly which ones, would love to find the biggest cpu usage drains. Count * average time or something? not quite sure if that's what usage does :P
Last edited by Tinkerboom : 05-04-06 at 07:12 PM.
Report comment to moderator  
Reply With Quote
Unread 05-06-06, 02:10 AM  
Shark
A Defias Bandit

Forum posts: 3
File comments: 56
Uploads: 0
why not divide by column_value or 1 to prevent divion by zero?
Report comment to moderator  
Reply With Quote
Unread 05-06-06, 02:13 AM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
Originally posted by Tinkerboom

I know a few of my mods are slowing me down a lot, but I haven't been able to figure out exactly which ones, would love to find the biggest cpu usage drains. Count * average time or something? not quite sure if that's what usage does :P
In the newest version (1.4.0.0) you can use the TsRC field to find out which function has used the most CPU time since the last reset.

For example, in the screenshot you see that HolyHope_CountKings used ~22 seconds while all other functions used ~5sec at most.
Report comment to moderator  
Reply With Quote
Unread 05-06-06, 02:14 AM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
Originally posted by Shark
why not divide by column_value or 1 to prevent divion by zero?
err.. that's what I'm doing.. I set Count to '1' and prevent the division by zero.. I don't understand what you mean
Last edited by wereHamster : 05-06-06 at 02:18 AM.
Report comment to moderator  
Reply With Quote
Unread 05-06-06, 11:18 PM  
Shark
A Defias Bandit

Forum posts: 3
File comments: 56
Uploads: 0
Originally posted by Shag
err.. that's what I'm doing.. I set Count to '1' and prevent the division by zero.. I don't understand what you mean
20 / 1 = 20
20 / (0 or 1) = 20

so you have a value time and a value count (how often the function was called), instead of dividing time / value you divide time / (value or 1) to prevent div by 0
Report comment to moderator  
Reply With Quote
Unread 05-07-06, 12:46 AM  
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view AddOns

Forum posts: 80
File comments: 15
Uploads: 4
Originally posted by Shark

time / (value or 1)

oh, now I see. Anyway.. the code in 1.4.0.0 is completely rewritten, you should see the corrent values there.
Report comment to moderator  
Reply With Quote
Unread 05-07-06, 06:47 AM  
Tinkerboom
A Kobold Labourer

Forum posts: 0
File comments: 4
Uploads: 0
1.4 seems to come up with completely different values than 1.3 did for me. And I cant see how they are correct either (tracking my chat frames as using the most resources), and if I put in Shard (to match shardtracker stuff, like I did before) I get nothing.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: