BIS fnc codePerformance – Talk
Categories: 
Lou Montana (talk | contribs) m (Text replacement - "<dd class="notedate">Posted on ([^<>]+) " to "<dd class="notedate">Posted on $1</dd> ")  | 
				Lou Montana (talk | contribs)  m (Text replacement - "<code>" to "<code style="display: block">")  | 
				||
| (2 intermediate revisions by the same user not shown) | |||
| Line 9: | Line 9: | ||
== notes from before the engine command ==  | == notes from before the engine command ==  | ||
<dt><dt>  | |||
<dd class="notedate">Posted on Mar 31, 2014 - 11:09</dd>  | <dd class="notedate">Posted on Mar 31, 2014 - 11:09</dd>  | ||
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note">  | <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.  | (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>['  | <code style="display: block">['  | ||
     [ { a = _this } ] [[spawn]] {  |      [ { a = _this } ] [[spawn]] {  | ||
         [[private]] "_code";  |          [[private]] "_code";  | ||
| Line 21: | Line 21: | ||
'] [[call]] [[BIS_fnc_codePerformance]];</code>  | '] [[call]] [[BIS_fnc_codePerformance]];</code>  | ||
There will be a great latency until GUI being displayed, never do like that, on the contrary, we should:  | There will be a great latency until GUI being displayed, never do like that, on the contrary, we should:  | ||
<code>['  | <code style="display: block">['  | ||
     {  |      {  | ||
         [[private]] "_code";  |          [[private]] "_code";  | ||
| Line 29: | Line 29: | ||
, [ {a = _this } ], 1000] [[call]] [[BIS_fnc_codePerformance]];</code>  | , [ {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:    | As for the third parameter, only run the code with desired loop and not always 1000 times like the default set:    | ||
<code>  | <code style="display: block">[‘  | ||
[‘  | |||
  a = 0; b = [[true]];  |   a = 0; b = [[true]];  | ||
  [[for]] [{_i = 0},{_i < 10 && b},{_i = _i + 1}] [[do]] {  |   [[for]] [{_i = 0},{_i < 10 && b},{_i = _i + 1}] [[do]] {  | ||
Latest revision as of 11:53, 11 January 2023
This is great function but needs an alternative syntax for convenience and ease of remembering:
{code} call BIS_fnc_codePerformance;
which would be set at default 10,000 iterations.
Please Karel, make it happen :)
notes from before the engine command
['
    [ { a = _this } ] spawn {
        private "_code";
        _code = [_this, 0, {}, [{}]] call BIS_fnc_param;
        { _x call _code; } forEach allUnits;
    };
'] call BIS_fnc_codePerformance;
There will be a great latency until GUI being displayed, never do like that, on the contrary, we should:
['
    {
        private "_code";
        _code = [_this, 0, {}, [{}]] call BIS_fnc_param;
        { _x call _code; } forEach allUnits;
    }'
, [ {a = _this } ], 1000] call BIS_fnc_codePerformance;
As for the third parameter, only run the code with desired loop and not always 1000 times like the default set: 
[‘
 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. 
So separating all three parameters and using them wisely are recommended.