Open dk1a opened 1 year ago
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 ?
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
The optimizer can put some things outside of the
startGasReport
/endGasReport
frame (usinggasReport
modifier doesn't change this). Usually it's unimportant, especially for costly functions, but it would be useful to have a way forgas-report
command to optionally include the cost of a whole test function (like whatforge 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)