{"name":"BIS_fnc_codePerformance","title":"BIS fnc codePerformance","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_codePerformance","revid":349499,"updated":"2023-11-08T17:09:10Z","groups":["Diagnostic"],"status":"ok","games":{"arma3":"0.50"},"since":"arma3 0.50","arma3_since":"0.50","description":"Measures how much time it takes to execute given expression.\nResults may vary based on overall performance; use this function to compare alternative scripting approaches rather than to measure specific values.\nUpon function execution, window with results is opened. The user then has a choice to copy the result into clipboard or not.\nThis function is using diag_codePerformance command.\n\n> [!NOTE]\n> Use toString to stringify Code, as str adds curly braces - See Example 2.","syntaxes":[{"syntax":"[expression, arguments, cycles, display] call BIS_fnc_codePerformance","params":[{"name":"expression","type":"String","description":"tested expression","type_expr":"String"},{"name":"arguments","type":"Anything","optional":true,"default":"`[]`","description":"arguments to pass into the code","type_expr":"Anything","text":"arguments: Anything - (Optional, default `[]`) arguments to pass into the code"},{"name":"cycles","type":"Number","optional":true,"default":"10000","description":"number of wanted cycles","type_expr":"Number","text":"cycles: Number - (Optional, default 10000) number of wanted cycles"},{"name":"display","type":"Display","optional":true,"default":"`findDisplay 46`","description":"display in which the message window with results will be opened. Use displayNull to disable the window","type_expr":"Display","text":"display: Display - (Optional, default `findDisplay 46`) display in which the message window with results will be opened. Use displayNull to disable the window"}],"returns":{"type":"Number","type_expr":"Number","description":"average execution time of the expression"}}],"examples":[{"code":["// compare three methods of adding elements into array\ntestArray = [];\n[\"testArray = testArray + [1]\"] call BIS_fnc_codePerformance;\ntestArray = [];\n[\"testArray set [count testArray, 1]\"] call BIS_fnc_codePerformance;\ntestArray = [];\n[\"testArray pushBack 1\"] call BIS_fnc_codePerformance;"]},{"code":["[toString { hint \"Hello there\" }] call BIS_fnc_codePerformance;"]}],"see_also":["diag_codePerformance"]}