I'm trying to figure out how to optimize one of my smart contracts for less billed CPU-usage.
There are typically different methods to optimize performance of algorithms but I'm not clear about if a high-performance smart-contract also results in less CPU-usage.
From the eos.io-whitepaper:
On a launched blockchain adopting the EOS.IO software, at a network level all transactions are billed a computational bandwidth cost based on the number of WASM instructions executed. However, each individual block producer using the software may calculate resource usage using their own algorithm and measurements.
Is this CPU-billing-scheme still in use?
A very basic example of a wasm-instruction is for example the sqrt instruction. Let's imagine i implement a more performant sqrt-algorithtm (i know it's nearly impossoble and i will never do that!) which doesn't use a single wasm sqrt and instead uses multiple shifts, subs and divs or whatever and therefore executes more WASM Instructions, will the billed CPU-usage for execution be higher?
Another different and very basic example is multiplying two int32 vs multiplying two floats. In traditional environemts multiplying two floats will result in slightly higher CPU-usage than when multiplying two integers - but if we only count wasm instructions both calculations execute the same amount of wasm instructions - 1.
To get to the Point:
If I want to optimize the code of a smart contract for less billed CPU-usage, do i have to write high-performance code - or do i have to reduce the amount of wasm instructions executed by the contract?