foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(`forge test`): generate gas report of all functions in contract without the need to specify a test function for each

Open iamkunal9 opened this issue 6 months ago • 1 comments

Component

Forge

Describe the feature you would like

The problem is that to obtain a gas report for an entire contract, we currently need to write test cases for each function within the contract. This is necessary to get accurate gas usage data. I'm looking for a way to generate a gas report without the need to write test cases for every function, if possible. Remix IDE offers something similar, but the results aren't very accurate.

A potential workaround is to build a script that automatically prefixes all functions in a contract with "test_" and then run forge snapshot to generate the gas report. However, if there were a way to achieve this without modifying the contract or writing specific test cases, it would be a much better solution.

Additional context

This feature would streamline the process of gas reporting, especially for large contracts where writing individual test cases for every function is cumbersome. #4486

iamkunal9 avatar Aug 22 '24 09:08 iamkunal9