Last active
June 20, 2023 03:35
-
-
Save ernestognw/b3a4d8a0f75d3c466ba61f325d81e640 to your computer and use it in GitHub Desktop.
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
## Optimizer ON with 200 runs | |
| src/ProposalSnapshot.sol:ProposalSnapshot contract | | | | | | | |
|----------------------------------------------------|-----------------|-------|--------|-------|---------| | |
| Deployment Cost | Deployment Size | | | | | | |
| 160808 | 835 | | | | | | |
| Function Name | min | avg | median | max | # calls | | |
| add | 23300 | 23300 | 23300 | 23300 | 2 | | |
| getMemory | 2667 | 2667 | 2667 | 2667 | 1 | | |
| getRaw | 2474 | 2474 | 2474 | 2474 | 1 | | |
## Optimizer ON with 200 runs and via-ir | |
| src/ProposalSnapshot.sol:ProposalSnapshot contract | | | | | | | |
|----------------------------------------------------|-----------------|-------|--------|-------|---------| | |
| Deployment Cost | Deployment Size | | | | | | |
| 120372 | 629 | | | | | | |
| Function Name | min | avg | median | max | # calls | | |
| add | 22907 | 22907 | 22907 | 22907 | 2 | | |
| getMemory | 2574 | 2574 | 2574 | 2574 | 1 | | |
| getRaw | 2378 | 2378 | 2378 | 2378 | 1 | |
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
## Optimizer ON with 200 runs | |
ProposalSnapshotTest:testGetMemory() (gas: 9953) | |
ProposalSnapshotTest:testGetRaw() (gas: 9761) | |
## Optimizer ON with 200 runs and via-ir | |
ProposalSnapshotTest:testGetMemory() (gas: 9979) | |
ProposalSnapshotTest:testGetRaw() (gas: 9629) |
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
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.13; | |
contract ProposalSnapshot { | |
struct ProposalCore { | |
address proposer; | |
uint48 voteStart; | |
uint32 voteDuration; | |
bool executed; | |
bool canceled; | |
} | |
mapping(uint256 => ProposalCore) private _proposals; | |
function add(uint256 proposalId, ProposalCore memory proposal) external { | |
_proposals[proposalId] = proposal; | |
} | |
function getMemory(uint256 proposalId) external view returns (uint256) { | |
ProposalCore memory proposal = _proposals[proposalId]; | |
return proposal.voteStart; | |
} | |
function getRaw(uint256 proposalId) external view returns (uint256) { | |
return _proposals[proposalId].voteStart; | |
} | |
} |
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
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.13; | |
import "forge-std/Test.sol"; | |
import {ProposalSnapshot} from "./ProposalSnapshot.sol"; | |
contract ProposalSnapshotTest is Test { | |
ProposalSnapshot public proposalSnapshot; | |
uint256 public proposalId = 1; | |
function setUp() public { | |
proposalSnapshot = new ProposalSnapshot(); | |
proposalSnapshot.add( | |
proposalId, | |
ProposalSnapshot.ProposalCore({ | |
proposer: address(1), | |
voteStart: 1, | |
voteDuration: 1, | |
executed: false, | |
canceled: false | |
}) | |
); | |
} | |
function testGetMemory() public { | |
proposalSnapshot.getMemory(proposalId); | |
} | |
function testGetRaw() public { | |
proposalSnapshot.getRaw(proposalId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment