Created
August 17, 2022 13:38
-
-
Save ViktorKuzmanov/08fd13936596fa7f18b090983a34f2cb to your computer and use it in GitHub Desktop.
Just a simple script that tests gas usage in remix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.0; | |
contract Gas { | |
uint public c = 1; | |
function notOptimized() external returns(uint gasUsed){ | |
uint startGas = gasleft(); | |
c++; | |
gasUsed = startGas - gasleft(); | |
} | |
function optimized() external returns(uint gasUsed){ | |
uint startGas = gasleft(); | |
++c; | |
gasUsed = startGas - gasleft(); | |
} | |
} | |
// 5161 | |
// 5167 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment