Skip to content

Instantly share code, notes, and snippets.

@ViktorKuzmanov
Created August 17, 2022 13:38
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 ViktorKuzmanov/08fd13936596fa7f18b090983a34f2cb to your computer and use it in GitHub Desktop.
Save ViktorKuzmanov/08fd13936596fa7f18b090983a34f2cb to your computer and use it in GitHub Desktop.
Just a simple script that tests gas usage in remix
// 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