Skip to content

Commit

Permalink
feat(gas-report): run gas report with --isolate (#2331)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Mar 5, 2024
1 parent 6878b50 commit 90d0d79
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-actors-refuse.md
@@ -0,0 +1,5 @@
---
"@latticexyz/gas-report": minor
---

Now uses `--isolate` flag in `forge test` for more accurate gas measurement.
2 changes: 1 addition & 1 deletion packages/gas-report/README.md
Expand Up @@ -26,7 +26,7 @@ pnpm gas-report --save gas-report.json
Or, if you have your own test command, you can pipe the output to `gas-report --stdin`:

```console
GAS_REPORTER_ENABLED=true forge test -vvv | pnpm gas-report --stdin
GAS_REPORTER_ENABLED=true forge test -vvv --isolate | pnpm gas-report --stdin
```

Run `pnpm gas-report --help` for more details.
2 changes: 1 addition & 1 deletion packages/gas-report/ts/index.ts
Expand Up @@ -114,7 +114,7 @@ async function runGasReport(options: Options): Promise<GasReport> {
console.log("Done reading stdin");
} else {
// Run the default test command to capture the logs
const child = execa("forge", ["test", "-vvv"], {
const child = execa("forge", ["test", "-vvv", "--isolate"], {
stdio: ["inherit", "pipe", "inherit"],
env: { GAS_REPORTER_ENABLED: "true" },
});
Expand Down
22 changes: 11 additions & 11 deletions packages/store/gas-report.json
Expand Up @@ -147,13 +147,13 @@
"file": "test/Gas.t.sol",
"test": "testCompareAbiEncodeVsCustom",
"name": "pass abi encoded bytes to external contract",
"gasUsed": 6549
"gasUsed": 29493
},
{
"file": "test/Gas.t.sol",
"test": "testCompareAbiEncodeVsCustom",
"name": "pass custom encoded bytes to external contract",
"gasUsed": 1426
"gasUsed": 23310
},
{
"file": "test/Gas.t.sol",
Expand Down Expand Up @@ -675,7 +675,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testDeleteDataOffchainTable",
"name": "StoreCore: delete record in offchain table",
"gasUsed": 4277
"gasUsed": 28225
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down Expand Up @@ -711,19 +711,19 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "set record on table with subscriber",
"gasUsed": 70986
"gasUsed": 98286
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "set static field on table with subscriber",
"gasUsed": 19248
"gasUsed": 52904
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "delete record on table with subscriber",
"gasUsed": 17197
"gasUsed": 47489
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -735,19 +735,19 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "set (dynamic) record on table with subscriber",
"gasUsed": 164119
"gasUsed": 191643
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "set (dynamic) field on table with subscriber",
"gasUsed": 24430
"gasUsed": 60374
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "delete (dynamic) record on table with subscriber",
"gasUsed": 18862
"gasUsed": 49266
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down Expand Up @@ -903,7 +903,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetDataOffchainTable",
"name": "StoreCore: set record in offchain table",
"gasUsed": 7681
"gasUsed": 32517
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -921,7 +921,7 @@
"file": "test/StoreHook.t.sol",
"test": "testCallHook",
"name": "call an enabled hook",
"gasUsed": 15032
"gasUsed": 37660
},
{
"file": "test/StoreHook.t.sol",
Expand Down

0 comments on commit 90d0d79

Please sign in to comment.