cgewecke / hardhat-gas-reporter

Gas Usage Analytics for Hardhat
MIT License
410 stars 56 forks source link

High gas view funcs not being reported #113

Closed 0xBeans closed 2 years ago

0xBeans commented 2 years ago

I have a view function (tokenURI) that processes onchain SVGs and uses ~15M in gas (according to foundry).

However, when running a similar test in HH and using gas reporter, tokenURI is left out from the gas reporter table (all other funcs are present). I assume it is due to the high gas usage of this function?

cgewecke commented 2 years ago

@0xBeans The gas reporter records gas usage by looking at transaction receipts and doesn't measure view or pure methods as such. You could get an approximation by executing the view in a state-changing wrapper like:

function executeTokenURI() external {
  tokenURI();
} 

(Issue #92 tracks adding support for view and pure methods as an option.)

0xBeans commented 2 years ago

Ah I see, I wasnt aware of that. Appreciate the info!