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"?
May be this is what you are looking for ?
claudio
November 15, 2023, 7:38pm
3
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.
/// Low-level interface to the Internet Computer.
///
/// **WARNING:** This low-level API is **experimental** and likely to change or even disappear.
import Prim "mo:⛔";
module {
/// Calls ``canister``'s update or query function, `name`, with the binary contents of `data` as IC argument.
/// Returns the response to the call, an IC _reply_ or _reject_, as a Motoko future:
///
/// * The message data of an IC reply determines the binary contents of `reply`.
/// * The error code and textual message data of an IC reject determines the future's `Error` value.
///
/// Note: `call` is an asynchronous function and can only be applied in an asynchronous context.
///
/// Example:
/// ```motoko no-repl
/// import IC "mo:base/ExperimentalInternetComputer";
/// import Principal "mo:base/Principal";
This file has been truncated. show original
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.
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