Gas benchmark for DiamondLoupeContract#165
Merged
mudgen merged 7 commits intoPerfect-Abstractions:mainfrom Nov 2, 2025
Merged
Conversation
Merged
Contributor
Coverage Report
Last updated: Sun, 02 Nov 2025 22:06:38 GMT for commit |
Contributor
Gas ReportNo gas usage changes detected between All functions maintain the same gas costs. ✅ Last updated: Sun, 02 Nov 2025 22:06:53 GMT for commit |
Contributor
|
Thanks, I am going to try this out! The formatting check |
Contributor
|
I tried it out, it works! |
JackieXu
pushed a commit
to JackieXu/Compose
that referenced
this pull request
Nov 6, 2025
…nd-gas-200facets Gas benchmark for DiamondLoupeContract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
To aid evaluation of #155.
Adds a reusable gas benchmark harness for Diamond Loupe. It spins up a minimal diamond, plugs in a user-provided loupe facet, and synthetically builds a large diamond in storage (default: 200 facets × 10 selectors) so anyone can drop in an optimised loupe and immediately measure gas for the four view functions.
Changes Made
To tests/benchmark, added:
MinimalDiamond.sol: adapted from a reference implementation.Base.t.sol: abstract test harness that deploysMinimalDiamondsetup with four loupe selectors, and builds complex storage for the diamond.Utils.sol: storage helpers, constants and builder functions.Benchmark.t.sol: baseline gas tests against currentDiamondLoupeFacet.Optimised.t.sol: same tests as the benchmark, but_deployLoupeshould be overriden with the optimised contract.Checklist
Before submitting this PR, please ensure:
Code follows the Solidity feature ban - No inheritance, constructors, modifiers, public/private variables, external library functions,
using fordirectives, orselfdestructCode follows Design Principles - Readable, uses diamond storage, favors composition over inheritance
Code matches the codebase style - Consistent formatting, documentation, and patterns (e.g. ERC20Facet.sol)
Code is formatted with
forge fmtTests are included - All new functionality has comprehensive tests
All tests pass - Run
forge testand ensure everything worksDocumentation updated - If applicable, update relevant documentation
Make sure to follow the CONTRIBUTING.md guidelines.
Additional Notes
Run benchmarks with:
forge test --mt LoupeGasBenchmarkTest -vvforge test --mt OptimisedLoupeBenchmarkTest -vv