I want to get execution cost every loop when function addData() was call. The solidity remix show execution cost when program run finish. How to show execution cost in each loop?
contract Test_loop {
uint256 number;
function testLoop() public{
uint256 i=0;
uint256 cnt=0;
for(i;i<100;i++) {
cnt++;
addData(cnt);
console.log(cnt);
}
}
function addData(uint256 _number) public{
number = _number;
}
}
REPORT_GAS=true npx hardhat test
, but should also show you a total gas cost.