-
Notifications
You must be signed in to change notification settings - Fork 2
Performance benchmarks and optimisations #184
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d1f5b77
Performance optimisations
tomusdrw 707bdd9
Performance benchmarks
tomusdrw 8f893b0
More optimistations
tomusdrw f55e883
Prevent excessive alloc in test
tomusdrw f803b7d
Another round of fixes
tomusdrw 6379542
rewrite
tomusdrw d894dad
fix ci
tomusdrw 0e57efb
No memory dumping
tomusdrw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,29 @@ | ||
| /** Gas type. */ | ||
| export type Gas = i64; | ||
| export type Gas = u64; | ||
|
|
||
| /** Create a new gas counter instance depending on the gas value. */ | ||
| export function gasCounter(gas: i64): GasCounter { | ||
| return new GasCounterU64(gas); | ||
| /** Create a new gas counter instance. */ | ||
| export function gasCounter(gas: Gas): GasCounter { | ||
| return new GasCounter(gas); | ||
| } | ||
|
|
||
| /** An abstraction over gas counter. | ||
| * | ||
| * It can be optimized to use numbers instead of bigint in case of small gas. | ||
| */ | ||
| export interface GasCounter { | ||
| /** Return remaining gas. */ | ||
| get(): Gas; | ||
|
|
||
| /** Overwite remaining gas. Prefer sub method instead. */ | ||
| set(g: Gas): void; | ||
|
|
||
| /** Returns true if there was an underflow. */ | ||
| sub(g: Gas): boolean; | ||
| } | ||
|
|
||
| class GasCounterU64 implements GasCounter { | ||
| export class GasCounter { | ||
| constructor(private gas: Gas) {} | ||
|
|
||
| set(g: Gas): void { | ||
| this.gas = i64(g); | ||
| this.gas = g; | ||
| } | ||
|
|
||
| get(): Gas { | ||
| return this.gas; | ||
| } | ||
|
|
||
| @inline | ||
| sub(g: Gas): boolean { | ||
| this.gas = this.gas - i64(g); | ||
| if (this.gas < i64(0)) { | ||
| this.gas = i64(0); | ||
| if (g > this.gas) { | ||
| this.gas = u64(0); | ||
| return true; | ||
| } | ||
| this.gas = this.gas - g; | ||
| return false; | ||
| } | ||
| } |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.