CBA_fnc_benchmarkFunction

Description

Benchmarks a function to see how long it will take to execute.

Recommended to run with small number of iterations first and build up, to prevent locking up the machine.

Parameters

_functionFunction to test [Function]
_parametersParameters to pass to the function on each iteration [Array or nil]
_iterationsNumber of iterations to run, in order to get an accurate average time [Number]

Returns

Average execution time [Number]

Examples

// Array creation through use of push.
_array = [];
_took = [{ _array set [count _array, 1] }, nil, 1000] call CBA_fnc_benchmarkFunction;

// Array creation through use of concatenation.
_array = [];
_took = [{ _array = _array + [1] }, nil, 1000] call CBA_fnc_benchmarkFunction;

// "Null function" to compare to (use as a control vs. operation time
//  of other functions).
_array = [];
_took = [{}, nil, 1000] call CBA_fnc_benchmarkFunction;

Author

Spooner

Close