-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add more gas cost measurements
- Loading branch information
1 parent
5f1ea31
commit 32fcec1
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
pallet/src/assets/move-projects/gas-costs/sources/ModuleNotModule.move
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
script { | ||
fun uses_no_module() { | ||
let a: u64 = 0; | ||
let sum: u64 = 0; | ||
let cnt = 0; | ||
|
||
while (cnt < 5000) { | ||
a = a + 1; | ||
sum = sum + a; | ||
cnt = cnt + 1; | ||
}; | ||
|
||
assert!(sum > 5000, 0); | ||
} | ||
} | ||
|
||
script { | ||
use DeveloperBob::TheModule; | ||
|
||
fun uses_module() { | ||
let a: u64 = 0; | ||
let sum: u64 = 0; | ||
let cnt = 0; | ||
|
||
while (cnt < 5000) { | ||
(sum, a) = TheModule::stupid_algorithm(sum, a); | ||
cnt = cnt + 1; | ||
}; | ||
|
||
assert!(sum > 5000, 0); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
pallet/src/assets/move-projects/gas-costs/sources/TheModule.move
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module DeveloperBob::TheModule { | ||
// Useless algorithm to test difference between function calls and direct implementation. | ||
public fun stupid_algorithm(sum: u64, a: u64): (u64, u64) { | ||
a = a + 1; | ||
sum = sum + a; | ||
return (sum, a) | ||
} | ||
} |
This file contains 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