BIS fnc codePerformance: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
(irrelevant info removed since this function is using engine command now)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| 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.
| 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 and timing is copied to clipboard. This functions is using [[diag_codePerformance]] command.


In Arma 3, window with results is opened afterwards.
'''NOTE:''' For best results restart your client before conducting tests. This function uses [[diag_tickTime]] which loses its precision the longer the client runs from restart.
<br>


[[File:BIS fnc codePerformance.png|300px]]
[[File:BIS fnc codePerformance.png|300px]]
Line 44: Line 40:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on Mar 31, 2014 - 11:09
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note">
(ArmA3 1.14) Please always take advantage of the second and third parameters when running code on [[BIS_fnc_codePerformance]]. And it is not suggested to use reserved variables under [[Scheduler#Scheduled_Environment|scheduled environment]]. E.g.
<code>['
    [ { a = _this } ] [[spawn]] {
        [[private]] "_code";
        _code = [_this, 0, {}, [{}]] [[call]] [[BIS_fnc_param]];
        { _x [[call]] _code; } [[forEach]] [[allUnits]];
    };
'] [[call]] [[BIS_fnc_codePerformance]];</code>
There will be a great latency until GUI being displayed, never do like that, on the contrary, we should:
<code>['
    {
        [[private]] "_code";
        _code = [_this, 0, {}, [{}]] [[call]] [[BIS_fnc_param]];
        { _x [[call]] _code; } [[forEach]] [[allUnits]];
    }'
, [ {a = _this } ], 1000] [[call]] [[BIS_fnc_codePerformance]];</code>
As for the third parameter, only run the code with desired loop and not always 1000 times like the default set:
<code>
[‘
a = 0; b = [[true]];
[[for]] [{_i = 0},{_i < 10 && b},{_i = _i + 1}] [[do]] {
  a = a + 1;
  [[if]] (a >= 7) [[then]] {b = [[false]]};
};’
,[],1000] [[call]] [[BIS_fnc_codePerformance]];
//Sometimes such 1000 loops will freeze the game directly.
</code>
So separating all three parameters and using them wisely are recommended.
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>

Revision as of 11:40, 21 June 2017

Hover & click on the images for description

Description

Description:
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 and timing is copied to clipboard. This functions is using diag_codePerformance command. BIS fnc codePerformance.png
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[expression(String),Any([parameters]),cycles(Number)] call BIS_fnc_codePerformance;
Parameters:
expression: String - tested expression
Any (Optional): Param(s) - passed into code (default: [])
cycles (Optional): Number - Number of cycles (default: 10000)
Return Value:
Nothing

Examples

Example 1:
testArray = []; ["testArray = testArray + [1];"] call BIS_fnc_codePerformance; testArray = []; ["testArray set [count testArray,1];"] call BIS_fnc_codePerformance; Compare two methods of adding elements into array

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

Notes

Bottom Section