Move.

Post

Share your knowledge.

Mister_CocaCola.
Mar 28, 2025
Discussion

Performance difference between modulo and comparison assertions?

I'm curious if using assert!(arg3 % arg0 == 0, 6); is more gas efficient than assert!(arg3 < arg0, 6);? I came across this in deepbook and was wondering about the choice. Is there any significant performance difference between using modulo versus comparison assertions in terms of gas consumption?

  • Move CLI
  • Move
1
1
Share
Comments
.

Answers

1
dudley_smith.
Mar 28 2025, 20:11

The latter (assert!(arg3 < arg0, 6);) will be slightly cheaper in terms of gas because it's a single instruction (Cmp) rather than three (Mod, LdConst<0>, Eq). However, it's generally not something to worry about due to gas bucketing. Arithmetic instructions tend to be much cheaper compared to other instructions. Also, the Sui gas model charges differently only for programs with consistently different wall-clock execution times, and arithmetic execution timings can naturally vary quite a bit. More details can be found in the Sui tokenomics documentation: https://docs.sui.io/concepts/tokenomics/gas-in-sui#computation.

1
Best Answer
Comments
.

Do you know the answer?

Please log in and share it.

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148Posts231Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignJune
    We use cookies to ensure you get the best experience on our website.
    More info