{"name":"diag_codePerformance","operator":null,"title":"diag codePerformance","type":"command","url":"https://community.bistudio.com/wiki/diag_codePerformance","revid":377699,"updated":"2026-01-02T09:03:27Z","groups":["Diagnostic","Performance Profiling"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.58"}],"since":{"game":"arma3","name":"Arma 3","version":"1.58"},"arma3_since":"1.58","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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.\nThe command will return as soon as possible if the tested code is slow and the duration of the command exceeds 1 second.\nEngine alternative to BIS_fnc_codePerformance.","syntaxes":[{"syntax":"diag_codePerformance [code, arguments, cycles]","since":null,"effect":null,"exec":null,"params":[{"name":"code","type":"Code","optional":false,"default":null,"description":"code to compare performance","types":["Code"],"since":null,"text":"code: Code - code to compare performance"},{"name":"arguments","type":"Anything","optional":true,"default":"nil","description":"arguments to pass to the code in _this variable. Default: nil","types":["Anything"],"since":null,"text":"arguments: Anything - (Optional, default nil) arguments to pass to the code in _this variable. Default: nil"},{"name":"cycles","type":"Number","optional":true,"default":"100000","description":"wanted number of cycles to run the given code. > 1000 is recommended","types":["Number"],"since":null,"text":"cycles: Number - (Optional, default 100000) wanted number of cycles to run the given code. > 1000 is recommended"},{"name":"ignoreTimeLimit","type":"Boolean","optional":true,"default":"false","description":"ignore the 1 second timelimit, and always run the provided number of cycles (except in multiplayer)","types":["Boolean"],"since":"arma3 2.14","text":"ignoreTimeLimit: Boolean - (Optional, default false) - ignore the 1 second timelimit, and always run the provided number of cycles (except in multiplayer)"}],"returns":{"type":"Array with [duration, cycles]","types":["Array"],"description":"duration: Number - average duration of 1 execution in milliseconds - cycles: Number - actual number of cycles executed","text":"Array with [duration, cycles]\n- duration: Number - average duration of 1 execution in milliseconds\n- cycles: Number - actual number of cycles executed"},"form":"unary","operator":null,"left":null,"right":{"text":"[code, arguments, cycles]","types":["Array"]}}],"examples":[{"text":"```sqf\nprivate _result = diag_codePerformance [{ private _a = 123; }, 0, 10000];\n```","code":["private _result = diag_codePerformance [{ private _a = 123; }, 0, 10000];"]}],"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.","problems":null,"aliases":[],"see_also":["diag_log","BIS_fnc_codePerformance","Code Optimisation"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Diagnostic","Command Group: Performance Profiling","Introduced with Arma 3 version 1.58","Scripting Commands"]}