Ic_cdk::api::instruction_counter in Motoko?

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"?

1 Like

May be this is what you are looking for ?

1 Like

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.

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.

2 Likes

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

You can go up to 20B instructions. It is configured here. Install/upgrade messages have more generous limits

2 Likes