Download
(2Kb)
Download
Updated: 04-22-07 08:18 PM
Pictures
File Info
Updated:04-22-07 08:18 PM
Created:unknown
Downloads:2,180
Favorites:1
MD5:

Benchmarker

Version: 1.0
by: RaeVanMorlock [More]

Provides a class to create a Benchmarker that can be used to compare the execuation times of various functions. Benchmarker may be used in either World of Warcraft or within a standard LUA shell.

Usage Example
local tester = Benchmarker:new()
tester:AddFunction("Some Func", somefunc)
tester:AddFunction("Other Func", otherfunc)
tester:Run()


Notes
A global variable, Benchmark, is provided as a default Benchmarker class in case you'd like to create a test without instantiating a new class.

Class Definition

Instantiation

Benchmarker:new() - Returns a new Benchmarker class by setting the table's metamethod to the Benchmarker class and initializing some default properties

Properties

Benchmarker.TestIterations - (Default: 1) The number of times each function should be ran in a loop before calculating the total execution time.

Benchmarker.DisplayAfterRun - (Default: true) If true, the class's DisplayResults() method will be called at the end of the Run() method.

Methods

Benchmarker:AddFunction([name,] func) - Adds a function to the current list of functions that are going to be tested. Optionally, a name may be supplied to refer to this function as.

Benchmarker:Clear() - Clears the list of functions. Useful when wanting to create a new test with the same object.

Benchmarker:Run() - Runs the test. Each function is called a number of times and the total execution time is recorded.

Benchmarker:DisplayResults() - Provides a basic display of the results, including each functions total time and which function was the fastest

Optional Files (0)


Post A Reply Comment Options
Unread 04-23-07, 10:11 AM  
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
AddOn Author - Click to view AddOns

Forum posts: 1935
File comments: 4939
Uploads: 19
I would suggest adding memory profiling as well, which often important when evaluating a piece of code.
__________________
"There's only one thing that I know how to do well and I've often been told that you only can do what you know how to do well, and that's be you-- be what you're like-- be like yourself. And so I'm having a wonderful time, but I'd rather be whistling in the dark..."
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: