BIS fnc codePerformance: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *arma3 * * *\| *([0-2]\.[0-9]{2}) * " to "|game1= arma3 |version1= $1 ")
m (Text replacement - "BIS fnc " to "BIS_fnc_")
(5 intermediate revisions by the same user not shown)
Line 6: Line 6:
|gr1= Diagnostic
|gr1= Diagnostic


|descr= [[File:BIS fnc codePerformance.png|300px|right]]Measures how much time it takes to execute given expression. Results may vary based on overall performance; use this function to compare alternative scripting approaches rather than to measure specific values. Upon function execution, window with results is opened. The user then has a choice to copy the result into clipboard or not. <br>
|descr= [[File:BIS_fnc_codePerformance.png|300px|right]]
Measures how much time it takes to execute given expression.
Results may vary based on overall performance; use this function to compare alternative scripting approaches rather than to measure specific values.
Upon function execution, window with results is opened. The user then has a choice to copy the result into clipboard or not.<br>
This function is using [[diag_codePerformance]] command.
This function is using [[diag_codePerformance]] command.
<br>
Keep in mind that this takes string, and that you can't pass <code>[[str]] _code</code> as string because that add's curly braces to the string.


|s1=[expression, arguments, cycles, display] call [[BIS_fnc_codePerformance]]
{{Feature|informative|Use [[toString]] to stringify [[Code]], as [[str]] adds curly braces - See {{Link|#Example 2}}.}}


|p1= expression: [[String]] - Tested expression
|s1= [expression, arguments, cycles, display] call [[BIS_fnc_codePerformance]]
|p2= arguments (Optional): [[Anything]] - Arguments to pass into the code.  Default: []


|p3= cycles (Optional): [[Number]] - Number of wanted cycles. Default: 10000
|p1= expression: [[String]] - tested expression
|p4= display (Optional): [[Display]] - Display in which the message window with results will be opened. Use [[displayNull]] to disable the window. Default: Current mission display


|r1=[[Number]] - Average execution time of the expression
|p2= arguments: [[Anything]] - (Optional, default []) arguments to pass into the code


|x1= <code>testArray = [];
|p3= cycles: [[Number]] - (Optional, default 10000) number of wanted cycles
["testArray = testArray + [1]"] [[call]] [[BIS_fnc_codePerformance]];
 
|p4= display: [[Display]] - (Optional, default <sqf inline>findDisplay 46</sqf>) display in which the message window with results will be opened. Use [[displayNull]] to disable the window
 
|r1= [[Number]] - Average execution time of the expression
 
|x1= <sqf>
// compare three methods of adding elements into array
testArray = [];
["testArray = testArray + [1]"] call BIS_fnc_codePerformance;
testArray = [];
testArray = [];
["testArray [[set]] [<nowiki/>[[count]] testArray, 1]"] [[call]] [[BIS_fnc_codePerformance]];
["testArray set [count testArray, 1]"] call BIS_fnc_codePerformance;
testArray = [];
testArray = [];
["testArray [[pushBack]] 1"] [[call]] [[BIS_fnc_codePerformance]];
["testArray pushBack 1"] call BIS_fnc_codePerformance;
</code>
</sqf>
Compare three methods of adding elements into array
 
|x2= <sqf>[toString { hint "Hello there" }] call BIS_fnc_codePerformance;</sqf>


|seealso= [[diag_codePerformance]]
|seealso= [[diag_codePerformance]]
}}
}}
[[Category:{{Name|tkoh}}: Functions|{{uc:codePerformance}}]]

Revision as of 12:15, 27 July 2022

Hover & click on the images for description

Description

Description:
BIS fnc codePerformance.png

Measures how much time it takes to execute given expression. Results may vary based on overall performance; use this function to compare alternative scripting approaches rather than to measure specific values. Upon function execution, window with results is opened. The user then has a choice to copy the result into clipboard or not.
This function is using diag_codePerformance command.

Use toString to stringify Code, as str adds curly braces - See Example 2.
Execution:
call
Groups:
Diagnostic

Syntax

Syntax:
[expression, arguments, cycles, display] call BIS_fnc_codePerformance
Parameters:
expression: String - tested expression
arguments: Anything - (Optional, default []) arguments to pass into the code
cycles: Number - (Optional, default 10000) number of wanted cycles
display: Display - (Optional, default findDisplay 46) display in which the message window with results will be opened. Use displayNull to disable the window
Return Value:
Number - Average execution time of the expression

Examples

Example 1:
// compare three methods of adding elements into array testArray = []; ["testArray = testArray + [1]"] call BIS_fnc_codePerformance; testArray = []; ["testArray set [count testArray, 1]"] call BIS_fnc_codePerformance; testArray = []; ["testArray pushBack 1"] call BIS_fnc_codePerformance;
Example 2:
[toString { hint "Hello there" }] call BIS_fnc_codePerformance;

Additional Information

See also:
diag_codePerformance

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note