diag codePerformance: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= |p3=" to "|Parameter2= |p3=")
m (Text replacement - "Eden" to "Eden")
 
(39 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:diag_codePerformance}}
{{RV|type=command
{{Command|Comments=
____________________________________________________________________________________________


| A3 |= Game
|game1= arma3
|1.58|Game Version= (number surrounded by NO SPACES)
|version1= 1.58
____________________________________________________________________________________________


| Attempts to run given code with given arguments given number of cycles in unscheduled environment and returns average time it took to run the code as well as actual number of executions performed. The command will return as soon as possible if the tested code is slow and the duration of the command exceeds 1 second. Engine alternative to [[BIS_fnc_codePerformance]]<br><br>
|gr1= Diagnostic
'''NOTE:''' For security purposes, this command will only run for 1 cycle in MP, unless in-game [[Mission_Editor:_Debug_Console_(Arma_3)|debug console]] is available via [[description.ext]] option or [[Eden]] attribute setting. |DESCRIPTION=
____________________________________________________________________________________________


| '''diag_codePerformance''' [code, arguments, cycles] |SYNTAX=
|gr2= Performance Profiling
|p1= [code, arguments, cycles]: [[Array]] |=
|p2= code: [[Code]] - code to compare performance |Parameter2=


|p3= arguments (Optional): [[Anything]] - arguments to pass to the code in _this variable. Default: [[nil]] |=
|descr= Attempts to run given code with given arguments given number of cycles in unscheduled environment and returns average time it took to run the code as well as actual number of executions performed.
|p4= cycles (Optional): [[Number]] - wanted number of cycles to run the given code. > 1000 is recommended. Default: 100000 |=
The command will return as soon as possible if the tested code is slow and the duration of the command exceeds 1 second.
| [[Array]] - format [duration, cycles], where:
Engine alternative to [[BIS_fnc_codePerformance]].
* duration: [[Number]] - average duration of 1 execution in milliseconds
* cycles: [[Number]] - actual number of cycles executed |RETURNVALUE=


|mp= For security purposes, this command will only run for 1 cycle in multiplayer, unless in-game [[Arma 3: Debug Console|debug console]] is available via [[Description.ext|description.ext]] option or [[:Category:Eden Editor|Eden]] attribute setting.


|x1= <code>_result = [[diag_codePerformance]] [{[[private]] _a = 123;}, 0, 10000];</code>|EXAMPLE1=
|s1= [[diag_codePerformance]] [code, arguments, cycles]
____________________________________________________________________________________________


| [[diag_log]], [[BIS_fnc_codePerformance]], [[Code_Optimisation|Code Optimisation]] |SEEALSO=
|p1= code: [[Code]] - code to compare performance


| |MPBEHAVIOUR=  
|p2= arguments: [[Anything]] - (Optional, default [[nil]]) arguments to pass to the code in _this variable. Default: [[nil]]
____________________________________________________________________________________________
}}


<h3 style='display:none'>Notes</h3>
|p3= cycles: [[Number]] - (Optional, default 100000) wanted number of cycles to run the given code. > 1000 is recommended
<dl class='command_description'>
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|p4= ignoreTimeLimit: [[Boolean]] - (Optional, default false) - ignore the 1 second timelimit, and always run the provided number of cycles (except in multiplayer)
</dl>
|p4since= arma3 2.14


<h3 style='display:none'>Bottom Section</h3>
|r1= [[Array]] format [duration, cycles], where:
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
* duration: [[Number]] - average duration of 1 execution in milliseconds
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
* cycles: [[Number]] - actual number of cycles executed
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
|x1= <sqf>private _result = diag_codePerformance [{ private _a = 123; }, 0, 10000];</sqf>
<!-- DISCONTINUE Notes -->
 
|seealso= [[diag_log]] [[BIS_fnc_codePerformance]] [[Code Optimisation]]
}}

Latest revision as of 13:22, 9 July 2023

Hover & click on the images for description

Description

Description:
Attempts to run given code with given arguments given number of cycles in unscheduled environment and returns average time it took to run the code as well as actual number of executions performed. The command will return as soon as possible if the tested code is slow and the duration of the command exceeds 1 second. Engine alternative to BIS_fnc_codePerformance.
Multiplayer:
For security purposes, this command will only run for 1 cycle in multiplayer, unless in-game debug console is available via description.ext option or Eden attribute setting.
Groups:
DiagnosticPerformance Profiling

Syntax

Syntax:
diag_codePerformance [code, arguments, cycles]
Parameters:
code: Code - code to compare performance
arguments: Anything - (Optional, default nil) arguments to pass to the code in _this variable. Default: nil
cycles: Number - (Optional, default 100000) wanted number of cycles to run the given code. > 1000 is recommended
since Arma 3 logo black.png2.14
ignoreTimeLimit: Boolean - (Optional, default false) - ignore the 1 second timelimit, and always run the provided number of cycles (except in multiplayer)
Return Value:
Array format [duration, cycles], where:
  • duration: Number - average duration of 1 execution in milliseconds
  • cycles: Number - actual number of cycles executed

Examples

Example 1:
private _result = diag_codePerformance [{ private _a = 123; }, 0, 10000];

Additional Information

See also:
diag_log BIS_fnc_codePerformance Code Optimisation

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