cgewecke / eth-gas-reporter

Gas usage per unit test. Average gas usage per method. A mocha reporter.
MIT License
603 stars 94 forks source link

Compare two different implementations of the same smart contract #245

Closed vrde closed 3 years ago

vrde commented 3 years ago

I have two different implementations of an ERC-721 token, and I'd like to compare the gas usage method by method (the have the same interface). I was thinking to run the same test suite on the two implementations, and output the gas report to a json file. Then write some code to display the differences in gas usage and integrate it with hardhat.

I found it's possible to output a json, but I don't know where to start, do you have any ideas?

cgewecke commented 3 years ago

Hi @vrde,

Yes! Someone made a similar project as part of a CS masters thesis, published to npm here:

https://www.npmjs.com/package/scenario-eth-gas-reporter

This was a while ago, so it's not integrated with hardhat.... but adapting/borrowing pieces of that might be a quick route to what you're looking for.

Example Output

exampleoutput

vrde commented 3 years ago

@cgewecke thanks for your prompt reply! It's exactly what I'm looking for.