Skip to content

Instantly share code, notes, and snippets.

@z0r0z
Created May 4, 2022 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z0r0z/4187d4f39b9a2a6e89941f9f8e86682b to your computer and use it in GitHub Desktop.
Save z0r0z/4187d4f39b9a2a6e89941f9f8e86682b to your computer and use it in GitHub Desktop.
pragma solidity ^0.8.0;
contract Check {
function check0(address[] calldata stuff) external view returns (uint256) {
uint256 startGas = gasleft();
uint256 counter;
for (uint256 i; i< stuff.length; i++) {
counter++;
}
return startGas - gasleft();
}
function check1(address[] calldata stuff) external view returns (uint256) {
uint256 startGas = gasleft();
uint256 counter;
uint256 len = stuff.length;
for (uint256 i; i< len; i++) {
counter++;
}
return startGas - gasleft();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment