{"name":"BIS_fnc_codePerformance","operator":null,"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","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma3","name":"Arma 3","version":"0.50"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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.\n\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","since":null,"effect":null,"exec":null,"params":[{"name":"expression","type":"String","optional":false,"default":null,"description":"tested expression","types":["String"],"since":null,"text":"expression: String - tested expression"},{"name":"arguments","type":"Anything","optional":true,"default":"`[]`","description":"arguments to pass into the code","types":["Anything"],"since":null,"text":"arguments: Anything - (Optional, default `[]`) arguments to pass into the code"},{"name":"cycles","type":"Number","optional":true,"default":"10000","description":"number of wanted cycles","types":["Number"],"since":null,"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","types":["Display"],"since":null,"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","types":["Number"],"description":"average execution time of the expression","text":"Number - average execution time of the expression"}}],"examples":[{"text":"```sqf\n// 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;\n```","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;"]},{"text":"```sqf\n[toString { hint \"Hello there\" }] call BIS_fnc_codePerformance;\n```","code":["[toString { hint \"Hello there\" }] call BIS_fnc_codePerformance;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["diag_codePerformance"],"notes":[],"categories":["Arma 3: Functions","Arma 3: New Functions","Function Group: Diagnostic","Functions","Introduced with Arma 3 version 0.50"],"docblock":null,"filled_from_docblock":[]}