Skip to content
Merged
35 changes: 21 additions & 14 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,37 @@ collect-gas-usage:
cargo r -p test --release -- --verbose --forc-test-only | ./scripts/compare-gas-usage/extract-gas-usage.sh

# This recipe should be used on snapshot tests that contains gas usage from `forc test`,
# because it will extract gas usage from all versions of the file and generate an html interactive report.
# because it will extract gas usage from all versions of the file
# revision_range: as used in git to select the versions of the file that gas will be extracted
# path: path to file to extract gas usage
# open: "-o" will open the default browser showing the report
# report: csv or html
# open: for "html", "-o" will open the report in the default browser
[linux]
[group('benchmark')]
collect-historic-gas-usage path open:
collect-historic-gas-usage revision_range path report open="":
#! /bin/bash
mkdir -p target
rm target/a.csv
rm target/a.html
rm target/a.csv &>> /dev/null
rm target/a.html &>> /dev/null
echo "test,gas,commit" > target/a.csv
for HASH in `git log --format='%H' -- {{path}}`; do
for HASH in `git log --format='%H' {{revision_range}} -- {{path}}`; do
TIMESTAMP=$(git show -s --format='%as-%ct-%H' "$HASH")
git --no-pager show "$HASH:{{path}}" | bash -c "scripts/compare-gas-usage/extract-gas-usage.sh $TIMESTAMP" >> target/a.csv
done
./scripts/csv2html/csv2html.sh target/a.csv >> target/a.html
if [ -n "{{open}}" ]; then
if which xdg-open &>> /dev/null
then
xdg-open target/a.html
elif which gnome-open &>> /dev/null
then
gnome-open target/a.html

if [ "{{report}}" = "html" ]; then
./scripts/csv2html/csv2html.sh target/a.csv >> target/a.html
if [ -n "{{open}}" ]; then
if which xdg-open &>> /dev/null
then
xdg-open target/a.html
elif which gnome-open &>> /dev/null
then
gnome-open target/a.html
fi
fi
else
clipivot max target/a.csv --rows=test --cols=commit --val=gas > target/b.csv
fi

[group('build')]
Expand Down
2 changes: 1 addition & 1 deletion scripts/csv2html/csv2html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ tail -n +2 "$1" | sed -e 's/^/<tr><td>/' -e 's/,/<\/td><td>/g' -e 's/$/<\/td><\/
echo " </tbody>
</table>
<body>
</html>"
</html>"
6 changes: 3 additions & 3 deletions sway-lib-std/src/codec.sw
Original file line number Diff line number Diff line change
Expand Up @@ -5359,17 +5359,17 @@ where
{
let first_parameter = encode(method_name);
let second_parameter = encode(args);
let params = encode((
let params = (
contract_id,
asm(a: first_parameter.ptr()) {
a: u64
},
asm(a: second_parameter.ptr()) {
a: u64
},
));
);

__contract_call(params.ptr(), coins, asset_id, gas);
__contract_call(&params, coins, asset_id, gas);
let ptr = asm() {
ret: raw_ptr
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: test/src/snapshot/mod.rs
assertion_line: 266
---
> forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract --test-threads 1 --logs --reverts
exit status: 0
Expand All @@ -9,25 +8,25 @@ output:
Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core)
Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib)
Compiling contract panicking_contract (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract)
Finished debug [unoptimized + fuel] target(s) [8.92 KB] in ???
Finished debug [unoptimized + fuel] target(s) [8.512 KB] in ???
Running 12 tests, filtered 0 tests

tested -- panicking_contract

test test_panicking_in_contract_self_impl ... ok (???, 1618 gas)
test test_panicking_in_contract_self_impl ... ok (???, 1245 gas)
revert code: 8000000000000001
├─ panic message: panicking in contract self impl
├─ panicked: in <Contract as PanickingContractAbi>::panicking_in_contract_self_impl
│ └─ at [email protected], src/main.sw:22:9
test test_directly_panicking_method ... ok (???, 2147 gas)
test test_directly_panicking_method ... ok (???, 1774 gas)
revert code: 8080000000000002
├─ panic message: Error C.
├─ panic value: C(true)
├─ panicked: in <Contract as Abi>::directly_panicking_method
│ └─ at [email protected], src/main.sw:28:9
decoded log values:
C(true), log rb: 5503570629422409978
test test_nested_panic_inlined ... ok (???, 3843 gas)
test test_nested_panic_inlined ... ok (???, 3470 gas)
revert code: 830000000540a013
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }])
Expand All @@ -39,7 +38,7 @@ C(true), log rb: 5503570629422409978
└─ at [email protected], src/main.sw:32:9
decoded log values:
E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978
test test_nested_panic_inlined_same_revert_code ... ok (???, 3843 gas)
test test_nested_panic_inlined_same_revert_code ... ok (???, 3470 gas)
revert code: 830000000540a013
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }])
Expand All @@ -51,7 +50,7 @@ E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString
└─ at [email protected], src/main.sw:32:9
decoded log values:
E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978
test test_nested_panic_non_inlined ... ok (???, 4171 gas)
test test_nested_panic_non_inlined ... ok (???, 3798 gas)
revert code: 838000000680c818
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }])
Expand All @@ -63,7 +62,7 @@ E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString
└─ at [email protected], src/main.sw:40:9
decoded log values:
E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978
test test_nested_panic_non_inlined_same_revert_code ... ok (???, 4171 gas)
test test_nested_panic_non_inlined_same_revert_code ... ok (???, 3798 gas)
revert code: 838000000680c818
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }])
Expand All @@ -75,7 +74,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d
└─ at [email protected], src/main.sw:40:9
decoded log values:
E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978
test test_generic_panic_with_unit ... ok (???, 2842 gas)
test test_generic_panic_with_unit ... ok (???, 2469 gas)
revert code: 828000000000800f
├─ panic value: ()
├─ panicked: in panicking_lib::generic_panic
Expand All @@ -84,7 +83,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d
└─ at [email protected], src/main.sw:48:9
decoded log values:
(), log rb: 3330666440490685604
test test_generic_panic_with_unit_same_revert_code ... ok (???, 2842 gas)
test test_generic_panic_with_unit_same_revert_code ... ok (???, 2469 gas)
revert code: 828000000000800f
├─ panic value: ()
├─ panicked: in panicking_lib::generic_panic
Expand All @@ -93,7 +92,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d
└─ at [email protected], src/main.sw:48:9
decoded log values:
(), log rb: 3330666440490685604
test test_generic_panic_with_str ... ok (???, 2794 gas)
test test_generic_panic_with_str ... ok (???, 2421 gas)
revert code: 818000000000700d
├─ panic message: generic panic with string
├─ panicked: in panicking_lib::generic_panic
Expand All @@ -102,7 +101,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d
└─ at [email protected], src/main.sw:56:9
decoded log values:
AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218
test test_generic_panic_with_different_str_same_revert_code ... ok (???, 2335 gas)
test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1962 gas)
revert code: 8180000000004007
├─ panic message: generic panic with different string
├─ panicked: in panicking_lib::generic_panic
Expand All @@ -111,7 +110,7 @@ AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218
└─ at [email protected], src/main.sw:60:9
decoded log values:
AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218
test test_generic_panic_with_error_type_enum ... ok (???, 2519 gas)
test test_generic_panic_with_error_type_enum ... ok (???, 2146 gas)
revert code: 8200000000005009
├─ panic message: Error A.
├─ panic value: A
Expand All @@ -121,7 +120,7 @@ AsciiString { data: "generic panic with different string" }, log rb: 10098701174
└─ at [email protected], src/main.sw:64:9
decoded log values:
A, log rb: 5503570629422409978
test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2751 gas)
test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2378 gas)
revert code: 820000000000600b
├─ panic message: Error B.
├─ panic value: B(42)
Expand All @@ -143,93 +142,93 @@ output:
Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core)
Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib)
Compiling contract panicking_contract (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract)
Finished release [optimized + fuel] target(s) [7.416 KB] in ???
Finished release [optimized + fuel] target(s) [7.024 KB] in ???
Running 12 tests, filtered 0 tests

tested -- panicking_contract

test test_panicking_in_contract_self_impl ... ok (???, 1183 gas)
test test_panicking_in_contract_self_impl ... ok (???, 869 gas)
revert code: 8000000000000000
├─ panic message: panicking in contract self impl
└─ panicked: in <Contract as PanickingContractAbi>::panicking_in_contract_self_impl
└─ at [email protected], src/main.sw:22:9
test test_directly_panicking_method ... ok (???, 1605 gas)
test test_directly_panicking_method ... ok (???, 1291 gas)
revert code: 8080000000000000
├─ panic message: Error C.
├─ panic value: C(true)
└─ panicked: in <Contract as Abi>::directly_panicking_method
└─ at [email protected], src/main.sw:28:9
decoded log values:
C(true), log rb: 5503570629422409978
test test_nested_panic_inlined ... ok (???, 2851 gas)
test test_nested_panic_inlined ... ok (???, 2537 gas)
revert code: 8300000000000000
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }])
└─ panicked: in panicking_lib::nested_panic_inlined
└─ at panicking_lib, src/lib.sw:35:5
decoded log values:
E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978
test test_nested_panic_inlined_same_revert_code ... ok (???, 2851 gas)
test test_nested_panic_inlined_same_revert_code ... ok (???, 2537 gas)
revert code: 8300000000000000
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }])
└─ panicked: in panicking_lib::nested_panic_inlined
└─ at panicking_lib, src/lib.sw:35:5
decoded log values:
E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978
test test_nested_panic_non_inlined ... ok (???, 3081 gas)
test test_nested_panic_non_inlined ... ok (???, 2767 gas)
revert code: 8380000000000000
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }])
└─ panicked: in panicking_lib::nested_panic_non_inlined
└─ at panicking_lib, src/lib.sw:41:9
decoded log values:
E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978
test test_nested_panic_non_inlined_same_revert_code ... ok (???, 3081 gas)
test test_nested_panic_non_inlined_same_revert_code ... ok (???, 2767 gas)
revert code: 8380000000000000
├─ panic message: Error E.
├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }])
└─ panicked: in panicking_lib::nested_panic_non_inlined
└─ at panicking_lib, src/lib.sw:41:9
decoded log values:
E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978
test test_generic_panic_with_unit ... ok (???, 2053 gas)
test test_generic_panic_with_unit ... ok (???, 1739 gas)
revert code: 8280000000000000
├─ panic value: ()
└─ panicked: in panicking_lib::generic_panic
└─ at panicking_lib, src/lib.sw:74:5
decoded log values:
(), log rb: 3330666440490685604
test test_generic_panic_with_unit_same_revert_code ... ok (???, 2053 gas)
test test_generic_panic_with_unit_same_revert_code ... ok (???, 1739 gas)
revert code: 8280000000000000
├─ panic value: ()
└─ panicked: in panicking_lib::generic_panic
└─ at panicking_lib, src/lib.sw:74:5
decoded log values:
(), log rb: 3330666440490685604
test test_generic_panic_with_str ... ok (???, 2057 gas)
test test_generic_panic_with_str ... ok (???, 1743 gas)
revert code: 8180000000000000
├─ panic message: generic panic with string
└─ panicked: in panicking_lib::generic_panic
└─ at panicking_lib, src/lib.sw:74:5
decoded log values:
AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218
test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1739 gas)
test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1425 gas)
revert code: 8180000000000000
├─ panic message: generic panic with different string
└─ panicked: in panicking_lib::generic_panic
└─ at panicking_lib, src/lib.sw:74:5
decoded log values:
AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218
test test_generic_panic_with_error_type_enum ... ok (???, 1860 gas)
test test_generic_panic_with_error_type_enum ... ok (???, 1546 gas)
revert code: 8200000000000000
├─ panic message: Error A.
├─ panic value: A
└─ panicked: in panicking_lib::generic_panic
└─ at panicking_lib, src/lib.sw:74:5
decoded log values:
A, log rb: 5503570629422409978
test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2023 gas)
test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 1709 gas)
revert code: 8200000000000000
├─ panic message: Error B.
├─ panic value: B(42)
Expand Down
Loading
Loading