# Compute Units

All notable changes in compute units usage will be documented in this file.

The changes are calculated by comparing the current results with the last version's results. Increase in usage is shown with 🔴 and decrease is shown with 🟢.

The programs and their tests are located in [/tests/bench](https://github.com/coral-xyz/anchor/tree/master/tests/bench).

> **Note**
> The results documented in this file are autogenerated. Running the tests will update the current results when necessary, manually editing the results should be avoided.

> **Warning**
> The results may vary depending on Solana version.

## [Unreleased]

Solana version: 1.16.0

| Instruction                 | Compute Units | +/- |
| --------------------------- | ------------- | --- |
| accountInfo1                | 1015          | -   |
| accountInfo2                | 1475          | -   |
| accountInfo4                | 1964          | -   |
| accountInfo8                | 3841          | -   |
| accountEmptyInit1           | 5817          | -   |
| accountEmpty1               | 1149          | -   |
| accountEmptyInit2           | 10402         | -   |
| accountEmpty2               | 1754          | -   |
| accountEmptyInit4           | 19508         | -   |
| accountEmpty4               | 2540          | -   |
| accountEmptyInit8           | 37265         | -   |
| accountEmpty8               | 5016          | -   |
| accountSizedInit1           | 5924          | -   |
| accountSized1               | 1214          | -   |
| accountSizedInit2           | 10680         | -   |
| accountSized2               | 1873          | -   |
| accountSizedInit4           | 19970         | -   |
| accountSized4               | 2762          | -   |
| accountSizedInit8           | 38122         | -   |
| accountSized8               | 5353          | -   |
| accountUnsizedInit1         | 6052          | -   |
| accountUnsized1             | 1338          | -   |
| accountUnsizedInit2         | 10929         | -   |
| accountUnsized2             | 1778          | -   |
| accountUnsizedInit4         | 20339         | -   |
| accountUnsized4             | 3136          | -   |
| accountUnsizedInit8         | 39096         | -   |
| accountUnsized8             | 5952          | -   |
| boxedAccountEmptyInit1      | 6034          | -   |
| boxedAccountEmpty1          | 888           | -   |
| boxedAccountEmptyInit2      | 10633         | -   |
| boxedAccountEmpty2          | 1401          | -   |
| boxedAccountEmptyInit4      | 19311         | -   |
| boxedAccountEmpty4          | 2424          | -   |
| boxedAccountEmptyInit8      | 37136         | -   |
| boxedAccountEmpty8          | 4659          | -   |
| boxedAccountSizedInit1      | 6130          | -   |
| boxedAccountSized1          | 917           | -   |
| boxedAccountSizedInit2      | 10828         | -   |
| boxedAccountSized2          | 1463          | -   |
| boxedAccountSizedInit4      | 19703         | -   |
| boxedAccountSized4          | 2543          | -   |
| boxedAccountSizedInit8      | 37919         | -   |
| boxedAccountSized8          | 4898          | -   |
| boxedAccountUnsizedInit1    | 6240          | -   |
| boxedAccountUnsized1        | 972           | -   |
| boxedAccountUnsizedInit2    | 11048         | -   |
| boxedAccountUnsized2        | 1570          | -   |
| boxedAccountUnsizedInit4    | 20138         | -   |
| boxedAccountUnsized4        | 2768          | -   |
| boxedAccountUnsizedInit8    | 38791         | -   |
| boxedAccountUnsized8        | 5347          | -   |
| boxedInterfaceAccountMint1  | 2296          | -   |
| boxedInterfaceAccountMint2  | 4129          | -   |
| boxedInterfaceAccountMint4  | 7783          | -   |
| boxedInterfaceAccountMint8  | 15281         | -   |
| boxedInterfaceAccountToken1 | 2023          | -   |
| boxedInterfaceAccountToken2 | 3582          | -   |
| boxedInterfaceAccountToken4 | 6692          | -   |
| boxedInterfaceAccountToken8 | 13098         | -   |
| interfaceAccountMint1       | 2364          | -   |
| interfaceAccountMint2       | 5030          | -   |
| interfaceAccountMint4       | 9803          | -   |
| interfaceAccountMint8       | 18400         | -   |
| interfaceAccountToken1      | 2091          | -   |
| interfaceAccountToken2      | 3948          | -   |
| interfaceAccountToken4      | 7547          | -   |
| interface1                  | 1059          | -   |
| interface2                  | 1479          | -   |
| interface4                  | 1900          | -   |
| interface8                  | 3646          | -   |
| program1                    | 1053          | -   |
| program2                    | 1467          | -   |
| program4                    | 1878          | -   |
| program8                    | 3598          | -   |
| signer1                     | 1018          | -   |
| signer2                     | 1484          | -   |
| signer4                     | 1984          | -   |
| signer8                     | 3880          | -   |
| systemAccount1              | 1072          | -   |
| systemAccount2              | 1590          | -   |
| systemAccount4              | 2195          | -   |
| systemAccount8              | 4305          | -   |
| uncheckedAccount1           | 1014          | -   |
| uncheckedAccount2           | 1475          | -   |
| uncheckedAccount4           | 1965          | -   |
| uncheckedAccount8           | 3841          | -   |

### Notable changes

---

## [0.28.0]

Solana version: 1.16.0

| Instruction                 | Compute Units | +/-                   |
| --------------------------- | ------------- | --------------------- |
| accountInfo1                | 1015          | 🔴 **+61 (6.39%)**    |
| accountInfo2                | 1475          | 🟢 **-92 (5.87%)**    |
| accountInfo4                | 1964          | 🟢 **-95 (4.61%)**    |
| accountInfo8                | 3841          | -                     |
| accountEmptyInit1           | 5817          | 🟢 **-141 (2.37%)**   |
| accountEmpty1               | 1149          | 🔴 **+59 (5.41%)**    |
| accountEmptyInit2           | 10402         | 🟢 **-172 (1.63%)**   |
| accountEmpty2               | 1754          | 🟢 **-98 (5.29%)**    |
| accountEmptyInit4           | 19508         | -                     |
| accountEmpty4               | 2540          | 🟢 **-106 (4.01%)**   |
| accountEmptyInit8           | 37265         | -                     |
| accountEmpty8               | 5016          | -                     |
| accountSizedInit1           | 5924          | 🟢 **-139 (2.29%)**   |
| accountSized1               | 1214          | 🔴 **+79 (6.96%)**    |
| accountSizedInit2           | 10680         | -                     |
| accountSized2               | 1873          | 🟢 **-93 (4.73%)**    |
| accountSizedInit4           | 19970         | -                     |
| accountSized4               | 2762          | -                     |
| accountSizedInit8           | 38122         | -                     |
| accountSized8               | 5353          | -                     |
| accountUnsizedInit1         | 6052          | 🟢 **-141 (2.28%)**   |
| accountUnsized1             | 1338          | 🔴 **+95 (7.64%)**    |
| accountUnsizedInit2         | 10929         | 🟢 **-113 (1.02%)**   |
| accountUnsized2             | 1778          | 🟢 **-115 (6.08%)**   |
| accountUnsizedInit4         | 20339         | -                     |
| accountUnsized4             | 3136          | 🔴 **+32 (1.03%)**    |
| accountUnsizedInit8         | 39096         | -                     |
| accountUnsized8             | 5952          | 🟢 **-99 (1.64%)**    |
| boxedAccountEmptyInit1      | 6034          | 🟢 **-126 (2.05%)**   |
| boxedAccountEmpty1          | 888           | 🟢 **-88 (9.02%)**    |
| boxedAccountEmptyInit2      | 10633         | 🟢 **-151 (1.40%)**   |
| boxedAccountEmpty2          | 1401          | 🟢 **-98 (6.54%)**    |
| boxedAccountEmptyInit4      | 19311         | -                     |
| boxedAccountEmpty4          | 2424          | 🟢 **-106 (4.19%)**   |
| boxedAccountEmptyInit8      | 37136         | -                     |
| boxedAccountEmpty8          | 4659          | 🟢 **-121 (2.53%)**   |
| boxedAccountSizedInit1      | 6130          | 🟢 **-126 (2.01%)**   |
| boxedAccountSized1          | 917           | 🟢 **-86 (8.57%)**    |
| boxedAccountSizedInit2      | 10828         | 🟢 **-147 (1.34%)**   |
| boxedAccountSized2          | 1463          | 🟢 **-91 (5.86%)**    |
| boxedAccountSizedInit4      | 19703         | -                     |
| boxedAccountSized4          | 2543          | 🟢 **-99 (3.75%)**    |
| boxedAccountSizedInit8      | 37919         | -                     |
| boxedAccountSized8          | 4898          | 🟢 **-105 (2.10%)**   |
| boxedAccountUnsizedInit1    | 6240          | 🟢 **-134 (2.10%)**   |
| boxedAccountUnsized1        | 972           | 🟢 **-97 (9.07%)**    |
| boxedAccountUnsizedInit2    | 11048         | 🟢 **-163 (1.45%)**   |
| boxedAccountUnsized2        | 1570          | 🟢 **-109 (6.49%)**   |
| boxedAccountUnsizedInit4    | 20138         | 🟢 **-213 (1.05%)**   |
| boxedAccountUnsized4        | 2768          | 🟢 **-131 (4.52%)**   |
| boxedAccountUnsizedInit8    | 38800         | -                     |
| boxedAccountUnsized8        | 5347          | 🟢 **-170 (3.08%)**   |
| boxedInterfaceAccountMint1  | 2296          | -                     |
| boxedInterfaceAccountMint2  | 4129          | 🔴 **+76 (1.88%)**    |
| boxedInterfaceAccountMint4  | 7783          | 🔴 **+245 (3.25%)**   |
| boxedInterfaceAccountMint8  | 15281         | 🔴 **+582 (3.96%)**   |
| boxedInterfaceAccountToken1 | 2023          | 🔴 **+286 (16.47%)**  |
| boxedInterfaceAccountToken2 | 3582          | 🔴 **+654 (22.34%)**  |
| boxedInterfaceAccountToken4 | 6692          | 🔴 **+1401 (26.48%)** |
| boxedInterfaceAccountToken8 | 13098         | 🔴 **+2893 (28.35%)** |
| interfaceAccountMint1       | 2364          | 🟢 **-166 (6.56%)**   |
| interfaceAccountMint2       | 5030          | 🔴 **+304 (6.43%)**   |
| interfaceAccountMint4       | 9803          | 🔴 **+372 (3.94%)**   |
| interfaceAccountMint8       | 18400         | 🔴 **+691 (3.90%)**   |
| interfaceAccountToken1      | 2091          | 🔴 **+336 (19.15%)**  |
| interfaceAccountToken2      | 3948          | 🔴 **+737 (22.95%)**  |
| interfaceAccountToken4      | 7547          | 🔴 **+1541 (25.66%)** |
| interface1                  | 1059          | 🔴 **+60 (6.01%)**    |
| interface2                  | 1479          | 🟢 **-95 (6.04%)**    |
| interface4                  | 1900          | 🟢 **-96 (4.81%)**    |
| interface8                  | 3646          | -                     |
| program1                    | 1053          | 🔴 **+54 (5.41%)**    |
| program2                    | 1467          | 🟢 **-106 (6.74%)**   |
| program4                    | 1878          | 🟢 **-120 (6.01%)**   |
| program8                    | 3598          | 🟢 **-53 (1.45%)**    |
| signer1                     | 1018          | 🔴 **+60 (6.26%)**    |
| signer2                     | 1484          | 🟢 **-92 (5.84%)**    |
| signer4                     | 1984          | 🟢 **-95 (4.57%)**    |
| signer8                     | 3880          | -                     |
| systemAccount1              | 1072          | 🔴 **+59 (5.82%)**    |
| systemAccount2              | 1590          | 🟢 **-96 (5.69%)**    |
| systemAccount4              | 2195          | 🟢 **-103 (4.48%)**   |
| systemAccount8              | 4305          | -                     |
| uncheckedAccount1           | 1014          | 🔴 **+61 (6.40%)**    |
| uncheckedAccount2           | 1475          | 🟢 **-92 (5.87%)**    |
| uncheckedAccount4           | 1965          | 🟢 **-95 (4.61%)**    |
| uncheckedAccount8           | 3841          | -                     |

### Notable changes

- Upgrading Solana to `1.16`. The difference in compute units usage between `0.27.0` and `0.28.0` is the direct result of upgrading Solana version(both build tools and crates) ([#2512](https://github.com/coral-xyz/anchor/pull/2512)).

---

## [0.27.0]

Solana version: 1.14.16

| Instruction                 | Compute Units | +/- |
| --------------------------- | ------------- | --- |
| accountInfo1                | 954           | N/A |
| accountInfo2                | 1567          | N/A |
| accountInfo4                | 2059          | N/A |
| accountInfo8                | 3856          | N/A |
| accountEmptyInit1           | 5958          | N/A |
| accountEmpty1               | 1090          | N/A |
| accountEmptyInit2           | 10574         | N/A |
| accountEmpty2               | 1852          | N/A |
| accountEmptyInit4           | 19557         | N/A |
| accountEmpty4               | 2646          | N/A |
| accountEmptyInit8           | 37541         | N/A |
| accountEmpty8               | 5043          | N/A |
| accountSizedInit1           | 6063          | N/A |
| accountSized1               | 1135          | N/A |
| accountSizedInit2           | 10783         | N/A |
| accountSized2               | 1966          | N/A |
| accountSizedInit4           | 19975         | N/A |
| accountSized4               | 2787          | N/A |
| accountSizedInit8           | 38381         | N/A |
| accountSized8               | 5359          | N/A |
| accountUnsizedInit1         | 6193          | N/A |
| accountUnsized1             | 1243          | N/A |
| accountUnsizedInit2         | 11042         | N/A |
| accountUnsized2             | 1893          | N/A |
| accountUnsizedInit4         | 20495         | N/A |
| accountUnsized4             | 3104          | N/A |
| accountUnsizedInit8         | 39419         | N/A |
| accountUnsized8             | 6051          | N/A |
| boxedAccountEmptyInit1      | 6160          | N/A |
| boxedAccountEmpty1          | 976           | N/A |
| boxedAccountEmptyInit2      | 10784         | N/A |
| boxedAccountEmpty2          | 1499          | N/A |
| boxedAccountEmptyInit4      | 19500         | N/A |
| boxedAccountEmpty4          | 2530          | N/A |
| boxedAccountEmptyInit8      | 37415         | N/A |
| boxedAccountEmpty8          | 4780          | N/A |
| boxedAccountSizedInit1      | 6256          | N/A |
| boxedAccountSized1          | 1003          | N/A |
| boxedAccountSizedInit2      | 10975         | N/A |
| boxedAccountSized2          | 1554          | N/A |
| boxedAccountSizedInit4      | 19884         | N/A |
| boxedAccountSized4          | 2642          | N/A |
| boxedAccountSizedInit8      | 38182         | N/A |
| boxedAccountSized8          | 5003          | N/A |
| boxedAccountUnsizedInit1    | 6374          | N/A |
| boxedAccountUnsized1        | 1069          | N/A |
| boxedAccountUnsizedInit2    | 11211         | N/A |
| boxedAccountUnsized2        | 1679          | N/A |
| boxedAccountUnsizedInit4    | 20351         | N/A |
| boxedAccountUnsized4        | 2899          | N/A |
| boxedAccountUnsizedInit8    | 39118         | N/A |
| boxedAccountUnsized8        | 5517          | N/A |
| boxedInterfaceAccountMint1  | 2299          | N/A |
| boxedInterfaceAccountMint2  | 4053          | N/A |
| boxedInterfaceAccountMint4  | 7538          | N/A |
| boxedInterfaceAccountMint8  | 14699         | N/A |
| boxedInterfaceAccountToken1 | 1737          | N/A |
| boxedInterfaceAccountToken2 | 2928          | N/A |
| boxedInterfaceAccountToken4 | 5291          | N/A |
| boxedInterfaceAccountToken8 | 10205         | N/A |
| interfaceAccountMint1       | 2530          | N/A |
| interfaceAccountMint2       | 4726          | N/A |
| interfaceAccountMint4       | 9431          | N/A |
| interfaceAccountMint8       | 17709         | N/A |
| interfaceAccountToken1      | 1755          | N/A |
| interfaceAccountToken2      | 3211          | N/A |
| interfaceAccountToken4      | 6006          | N/A |
| interface1                  | 999           | N/A |
| interface2                  | 1574          | N/A |
| interface4                  | 1996          | N/A |
| interface8                  | 3651          | N/A |
| program1                    | 999           | N/A |
| program2                    | 1573          | N/A |
| program4                    | 1998          | N/A |
| program8                    | 3651          | N/A |
| signer1                     | 958           | N/A |
| signer2                     | 1576          | N/A |
| signer4                     | 2079          | N/A |
| signer8                     | 3895          | N/A |
| systemAccount1              | 1013          | N/A |
| systemAccount2              | 1686          | N/A |
| systemAccount4              | 2298          | N/A |
| systemAccount8              | 4336          | N/A |
| uncheckedAccount1           | 953           | N/A |
| uncheckedAccount2           | 1567          | N/A |
| uncheckedAccount4           | 2060          | N/A |
| uncheckedAccount8           | 3855          | N/A |

---
