---
name: "BIS_fnc_codePerformance"
type: function
status: ok
groups: ["Diagnostic"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_codePerformance
revid: 349499
updated: 2023-11-08T17:09:10Z
---

# BIS_fnc_codePerformance

*Function · Diagnostic · Arma 3 v0.50*

## Description

Measures how much time it takes to execute given expression.
Results may vary based on overall performance; use this function to compare alternative scripting approaches rather than to measure specific values.
Upon function execution, window with results is opened. The user then has a choice to copy the result into clipboard or not.

This function is using [diag_codePerformance](../commands/diag_codePerformance.md) command.

> [!NOTE]
> Use [toString](../commands/toString.md) to stringify [Code](../topics/Code.md), as [str](../commands/str.md) adds curly braces - See [#Example 2](../functions/BIS_fnc_codePerformance.md#example-2).

## Syntax

```sqf
[expression, arguments, cycles, display] call BIS_fnc_codePerformance
```

**Parameters:**

- `expression`: [String](../topics/String.md) - tested expression
- `arguments`: [Anything](../topics/Anything.md) - (Optional, default `[]`) arguments to pass into the code
- `cycles`: [Number](../topics/Number.md) - (Optional, default 10000) number of wanted cycles
- `display`: [Display](../topics/Display.md) - (Optional, default `findDisplay 46`) display in which the message window with results will be opened. Use [displayNull](../commands/displayNull.md) to disable the window

**Returns:** [Number](../topics/Number.md) - average execution time of the expression

## Examples

### Example 1

```sqf
// compare three methods of adding elements into array
testArray = [];
["testArray = testArray + [1]"] call BIS_fnc_codePerformance;
testArray = [];
["testArray set [count testArray, 1]"] call BIS_fnc_codePerformance;
testArray = [];
["testArray pushBack 1"] call BIS_fnc_codePerformance;
```

### Example 2

```sqf
[toString { hint "Hello there" }] call BIS_fnc_codePerformance;
```

## See also

[diag_codePerformance](../commands/diag_codePerformance.md)

<sub>Source: [BI Community Wiki — BIS fnc codePerformance](https://community.bistudio.com/wiki/BIS_fnc_codePerformance) (revision 349499).</sub>
