Testing call vs query speed in candid interface

You can use the candid interface to test the speed of canister calls.

In particular you can use it to see the difference between canister calls, which can make state changes, and queries, which cannot (because of this queries are much faster, so it’s worth using them where possible in your services and applications).

Try this:

actor {
	var x: Nat = 0;
	public func setValue(m: Nat) : async Nat {
		x := m;
		return x;
	};
	public query func getValue() : async Nat {
		return x;
	};
};

Open the canister’s candid interface in a browser http://localhost:8000/candid?canisterId=ic:<canister_id> and make some calls and queries, and you’ll find the response times output on the right.

If you also look in the replica console output, you’ll see that the queries do not create checkpoints (which are snapshots of the state changes).

4 Likes