Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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