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

Support different method call scenarios #272

Open drortirosh opened 2 years ago

drortirosh commented 2 years ago

First, I must say its an easy, intuitive tool for gas reporting. Minimal configuration to get result.

But sometimes, you do need explicit configuration: I have a method I want to test is different scenarios, and not average them all into a single number

e.g. I want the output like:

·················|····················|·············|·············|·············|···············|··············
|  Contract      ·  Method            ·  Min        ·  Max        ·  Avg        ·  # calls      ·  eur (avg)  │
·················|····················|·············|·············|·············|···············|··············
|  MyContract    ·  myMethod          ·      29600  ·      46700  ·      35300  ·            3  ·          -  │
·················|····················|·············|·············|·············|···············|··············
|  MyContract    ·  myMethod (heavy)  ·      70393  ·      87469  ·      76097  ·            3  ·          -  │
·················|····················|·············|·············|·············|···············|··············

Maybe it can be done by adding to specific tests:

methodUseCase(myContract, "myMethod", "heavy")
cgewecke commented 2 years ago

Ah! This is a good idea. Will think about how this could be done....

Martibis commented 2 years ago

Just came here to suggest the same thing, one clear usecase would be testing NFT mints where (e.g.: 1 mint vs 10 mints) from the same method would have a big difference in gas cost. I'd like to see the output for each separate call rather than the avg.