Gas Report
Measure and report gas usage within forge tests
Add some reports to your forge tests
import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
contract ExampleTest is Test, GasReporter {
function testGas() public {
startGasReport("description of behavior to measure gas for");
// do something here
endGasReport();
}
}
Then use the cli command to run tests and save the report:
pnpm gas-report --save gas-report.json
Or, if you have your own test command, you can pipe the output to gas-report --stdin
:
GAS_REPORTER_ENABLED=true forge test -vvv --isolate | pnpm gas-report --stdin
Run pnpm gas-report --help
for more details.
Version 2.2.6
Release date: Thu Sep 19 2024
Patch changes
feat(stash): release package to npm (#3184) (@latticexyz/stash)
Added @latticexyz/stash
package, a TypeScript client state library optimized for the MUD Store data model.
It uses the MUD store config to define local tables, which support writing, reading and subscribing to table updates.
It comes with a query engine optimized for "ECS-style" queries (similar to @latticexyz/recs
) but with native support for composite keys.
You can find usage examples in the @latticexyz/stash
README.md.
This package is experimental and will have breaking changes while we refine its APIs and implementation. All of its exports are temporarily under @latticexyz/stash/internal
until we consider it stable.
fix(cli): improve performance of linked library resolution during deployment (#3197) (@latticexyz/cli)
Significantly improved the deployment performance for large projects with public libraries by implementing a more efficient algorithm to resolve public libraries during deployment.
The local deployment time on a large reference project was reduced from over 10 minutes to 4 seconds.
feat(store-sync): add syncToStash util (#3192) (@latticexyz/store-sync)
Added a syncToStash
util to hydrate a stash
client store from MUD contract state. This is currently exported from @latticexyz/store-sync/internal
while Stash package is unstable/experimental.
import { createClient, http } from "viem";
import { anvil } from "viem/chains";
import { createStash } from "@latticexyz/stash/internal";
import { syncToStash } from "@latticexyz/store-sync/internal";
import config from "../mud.config";
const client = createClient({
chain: anvil,
transport: http(),
});
const address = "0x...";
const stash = createStash(config);
const sync = await syncToStash({ stash, client, address });