An algorithm is considered to be efficient if its running time is polynomial in the size of the input, and highly efficient if its running time is linear in the size of the input. It is important for all on-chain algorithms to be highly efficient, because they must scale linearly as the size of the Polkadot network grows. In contrast, off-chain algorithms are only required to be efficient. - Web3 Research
Moreover, any resources used by a transaction must explicitly be paid for within the module. If the resources used might be dependent on transaction parameters or pre-existing chain state, the in-module fee structure must adapt accordingly. Specifically, measuring the balance between resources used and price paid is an important design activity for runtime security.