Good day, everyone! Can somebody explain how I can calculate or forecast of my contract CPU usage in mainnet on some period? I want to understand the process of identification the factors that define real values of cpu bandwith in the future.
-
pretty much impossible at the moment.. just a few days the wasm interpreted was updated to work 2x faster so any CPU calculations before that were invalidated. similar things may happen in the future or if BPs upgrade their machines– confused00Commented Sep 27, 2018 at 22:27
-
@confused00 when will the new interpreter coming?– Jimmy GuoCommented Sep 28, 2018 at 5:51
-
@JimmyGuo it already did in v1.3.0 github.com/EOSIO/eos/releases/tag/v1.3.0– confused00Commented Sep 28, 2018 at 13:47
2 Answers
As far as i know, You cannot calculate exactly CPU usage. With the same transaction will have different cost depending on BPs and network condition.
But you can forecast your CPU usage in smart contract by estimate how many transactions and how much does it costs for these transactions.
Example: You Dapp will have 100 transaction/day, CPU usage average ~ 1ms/transaction. --> This mean, you need 100ms CPU/day
More detail, you can refer here https://medium.com/leclevietnam/eos-resource-allocation-98bb6cb84497
You can now estimate your costs for a transaction by using EOS New York's EOS Charge.
Methodology:
There is a MongoDB query that runs hourly. This query averages the CPU and NET resource costs experienced for every action performed on the EOS Mainnet within the last 100,000 blocks