Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): replace gas report #1049

Merged
merged 11 commits into from
Jun 20, 2023
Prev Previous commit
Next Next commit
update comment
holic committed Jun 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0244cae919a21f34f8a47360ebdcf66ce72ba1a7
11 changes: 7 additions & 4 deletions packages/cli/src/commands/gas-report.ts
Original file line number Diff line number Diff line change
@@ -7,18 +7,21 @@ import stripAnsi from "strip-ansi";

/**
* Print the gas report to the console, save it to a file and compare it to a previous gas report if provided.
* Requires forge to be installed, and gas test files including `// !gasreport` comments, like this:
*
* Requires foundry to be installed. Inherit from GasReporter and use startGasReport/endGasReport to measure gas used.
*
* ```solidity
* contract GasTest is DSTestPlus {
* contract MyContractTest is Test, GasReporter {
* function testBuffer() public pure {
* // !gasreport allocate a buffer
* startGasReport("allocate a buffer");
* Buffer buffer = Buffer_.allocate(32);
* endGasReport();
*
* bytes32 value = keccak256("some data");
*
* // !gasreport append 32 bytes to a buffer
* startGasReport("append 32 bytes to a buffer");
* buffer.append(value);
* endGasReport();
* }
* }
* ```