BIS fnc codePerformance: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Generated by BIS_fnc_exportFunctionsToWiki)
 
m (Text replacement - "(Optional, default {{hl|[]}})" to "(Optional, default <sqf inline>[]</sqf>)")
 
(69 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 0.50


| tkoh |= Game name
|gr1= Diagnostic


|1.00|= Game version
|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.


| <pre>/*
{{Feature|informative|Use [[toString]] to stringify [[Code]], as [[str]] adds curly braces - See {{Link|#Example 2}}.}}


Description:
|s1= [expression, arguments, cycles, display] call [[BIS_fnc_codePerformance]]
Measures how much time it takes to execute given expression


Parameter(s):
|p1= expression: [[String]] - tested expression
_this select 0: STRING - tested expression
_this select 1 (Optional): ANY - Param(s) passed into code (default: [])
_this select 2 (Optional): NUMBER - Number of cycles (default: 10000)


Returns:
|p2= arguments: [[Anything]] - (Optional, default <sqf inline>[]</sqf>) arguments to pass into the code
NUMBER - avarage time spend in code execution [ms]
*/
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_codePerformance]]; --> |= Syntax
|p3= cycles: [[Number]] - (Optional, default 10000) number of wanted cycles


|p1= |= Parameter 1
|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


| |= Return value
|r1= [[Number]] - average execution time of the expression
____________________________________________________________________________________________


|x1= <code></code> |=
|x1= <sqf>
____________________________________________________________________________________________
// 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;
</sqf>


| |= See also
|x2= <sqf>[toString { hint "Hello there" }] call BIS_fnc_codePerformance;</sqf>


|seealso= [[diag_codePerformance]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Debug|{{uc:codePerformance}}]]
[[Category:Functions|{{uc:codePerformance}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:codePerformance}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:codePerformance}}]]

Latest revision as of 18:09, 8 November 2023

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