Skip to content

Instantly share code, notes, and snippets.

@eternauta1337
Created April 10, 2019 11:37
Show Gist options
  • Save eternauta1337/9ff33cffa62c52f63f387a1569834dc1 to your computer and use it in GitHub Desktop.
Save eternauta1337/9ff33cffa62c52f63f387a1569834dc1 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.1+commit.c8a2cb62.js&optimize=false&gist=
pragma solidity ^0.5.0;
contract Loopy {
// 7750 gas
// 5732 gas (optimized)
function loop_1() public pure returns (uint acum) {
for(uint i = 0; i < 100; i++) {
acum++;
}
}
// 6728 gas
// 5710 gas (optimized)
function loop_2() public pure returns (uint acum) {
for(uint i = 0; i < 100; ++i) {
++acum;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment