Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gas-report vs optimizer #1267

Open
dk1a opened this issue Aug 9, 2023 · 2 comments
Open

gas-report vs optimizer #1267

dk1a opened this issue Aug 9, 2023 · 2 comments

Comments

@dk1a
Copy link
Contributor

dk1a commented Aug 9, 2023

The optimizer can put some things outside of the startGasReport/endGasReport frame (using gasReport modifier doesn't change this).
Usually it's unimportant, especially for costly functions, but it would be useful to have a way for gas-report command to optionally include the cost of a whole test function (like what forge test --gas-report --mt testName returns), ideally only the contents, without the function's overhead

(on 2nd thought, although I mention the optimizer it could be the compiler. I didn't delve into the specifics of everything that's going on here)

@alvrs
Copy link
Member

alvrs commented Aug 14, 2023

is it possible to disable the optimizer via an env variable that we can set while generating the gas report, similar to here: https://github.com/latticexyz/mud/blob/main/packages/gas-report/ts/index.ts#L105 ?

@dk1a
Copy link
Contributor Author

dk1a commented Aug 14, 2023

is it possible to disable the optimizer via an env variable that we can set while generating the gas report, similar to here: https://github.com/latticexyz/mud/blob/main/packages/gas-report/ts/index.ts#L105 ?

That env var isn't a foundry thing, it's just used for conditional things within solidity.
Optimizer is a compiler flag so I don't think you can disable it for specific lines/tests/files. You could run a second set of tests without an optimizer, though that's a hassle.
Anyways it wouldn't be very useful imo, unoptimized code costs more gas and isn't representative of the real gas usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants