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