# Ic\_cdk::api::instruction\_counter in Motoko?

**URL:** <https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720>\
**Category:** Getting Started\
**Created:** [November 15, 2023, 5:58pm UTC](https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720 "2023-11-15T17:58:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ildefons](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ildefons/32/2638_2.png) [@ildefons](https://forum.dfinity.org/u/ildefons)\
**Post date:** [November 15, 2023, 5:58pm UTC](https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720/1 "2023-11-15T17:58:36Z")

</div>

Does it exist `ic_cdk::api::instruction_counter` in Motoko? If not, is it somehow possible toretrieve " the number of instructions that the canister executed since the last entry point"?

---

<div class="post-metadata">

**Author:** ![h1teshtr1path1](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/h1teshtr1path1/32/24662_2.png) [@h1teshtr1path1](https://forum.dfinity.org/u/h1teshtr1path1)\
**Post date:** [November 15, 2023, 6:17pm UTC](https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720/2 "2023-11-15T18:17:17Z")

</div>

> **[ExperimentalInternetComputer | Internet Computer](https://internetcomputer.org/docs/current/motoko/main/base/ExperimentalInternetComputer#function-countinstructions)**
>
> Low-level interface to the Internet Computer.

May be this is what you are looking for ?

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [November 15, 2023, 7:38pm UTC](https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720/3 "2023-11-15T19:38:38Z")

</div>

That function will let you measure the instruction cost of some synchronous code only.

The implementation is here and uses performanceCounter(0), which is reset on entry but also after every await.

> <https://github.com/dfinity/motoko-base/blob/master/src/ExperimentalInternetComputer.mo>

There is a new performance counter (pass 1, not 0), that (should) let you measure instructions across awaits too.

Beware, I have not tried this yet.

---

<div class="post-metadata">

**Author:** ![ildefons](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ildefons/32/2638_2.png) [@ildefons](https://forum.dfinity.org/u/ildefons)\
**Post date:** [November 20, 2023, 12:18pm UTC](https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720/4 "2023-11-20T12:18:25Z")

</div>

My canister method takes ~18 Million instructions. What is the maximum number of cycles that can be executed within one consensu round?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [November 20, 2023, 12:23pm UTC](https://forum.dfinity.org/t/ic-cdk-instruction-counter-in-motoko/24720/5 "2023-11-20T12:23:10Z")

</div>

You can go up to 20B instructions. It is configured [here](https://github.com/dfinity/ic/blob/master/rs/config/src/subnet_config.rs#L18). Install/upgrade messages have more generous limits
