foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Don't count ```console.log()``` gas consumption inside the gas report

Open 0xCaso opened this issue 3 years ago • 3 comments

Component

Forge

Describe the feature you would like

This is really a minor thing, but, if worth it, it would be cool to exclude the gas consumed by console.log() from the report.

Additional context

No response

0xCaso avatar Oct 20 '22 11:10 0xCaso

+1

algtm avatar Feb 26 '24 12:02 algtm

My proposal here: https://github.com/foundry-rs/foundry/issues/2056#issuecomment-2237053678 would likely address this issue in a more generalised way by giving you the ability to define a section over which the gas is captured. This doesn't automatically filter out the console.log but I think it makes it possible to be much more precise about what you are measuring.

zerosnacks avatar Aug 07 '24 11:08 zerosnacks

Hi @0xCaso / @algtm

In https://github.com/foundry-rs/foundry/pull/8952 I've added support for gas snapshots over sections using cheatcodes. Would be great to get feedback on this.

To not include console.log you would simply not include it as part of your section you measure over

zerosnacks avatar Oct 17 '24 12:10 zerosnacks

Marking as effectively resolved by https://github.com/foundry-rs/foundry/pull/8952

zerosnacks avatar Oct 21 '24 12:10 zerosnacks