I am interested to analyze the execution cost of the function by considering the best practice to adopt, because of that I used bytes32 rather than String which decrease the execution cost of the function from infinite to finite.
I am eager to know whats the best way to find the accurate gas execution cost. I compile the same code 2-3 times in remix and sometimes it gives me the different execution gas cost. Like for below function sometimes it gives me
Execution cost: 624gas
and sometimes
Execution cost: 454 gas.
The function is below which simply return the length of an array.
function totalLoans() public view returns (uint){
return(allLoansData.length);
}
1) Does the difficulty parameter also impact the execution gas cost? 2) Is there any way that we find the ideal gas cost?