I heard two variants of reality:
- As of July 2022, ten instructions are equivalent to four cycles on an application subnet.
- Instructions are currently the same as cycles.
Which is true?
I heard two variants of reality:
Which is true?
Also, do instructions account to such things as creating a new canister (and for transferring remaining cycles to the newly created canister)?
The following example prints:
Spent cycles: 29_009
It follows that only actual instructions are counted. Neither cycles spent for canister creation nor cycles copied to the canister are counted.
import Nat64 "mo:base/Nat64";
import IC "mo:base/ExperimentalInternetComputer";
// import Cycles "mo:base/ExperimentalCycles";
import Debug "mo:base/Debug";
import {ic} "mo:ic";
actor {
public shared func greet<system>() : async () {
let instructionsCounter = IC.performanceCounter(1);
ignore await (with cycles = 4_000_000_000_000) ic.create_canister({
settings = ?{
freezing_threshold = null;
controllers = null;
reserved_cycles_limit = null;
log_visibility = null;
wasm_memory_limit = null;
memory_allocation = null;
compute_allocation = null;
};
sender_canister_version = null;
});
let spentCycles = Nat64.toNat(IC.performanceCounter(1) - instructionsCounter);
Debug.print("Spent cycles: " # debug_show(spentCycles));
};
};
It is the former. For more details on pricing please see here: Cycles cost formulas | Internet Computer