Skip to content

Commit 703219f

Browse files
committed
use foundry gas snapshots
1 parent 2c12768 commit 703219f

27 files changed

+577
-269
lines changed

.gas-snapshot

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
ArrayTest:test_Array_empty() (gas: 560)
2-
ArrayTest:test_Array_large() (gas: 607)
3-
ArrayTest:test_Array_mixed() (gas: 2071)
4-
ArrayTest:test_Array_nested() (gas: 2280)
5-
ArrayTest:test_Array_single() (gas: 964)
6-
BignumTest:test_Integer() (gas: 12559)
7-
BignumTest:test_NInt256_max() (gas: 1697)
8-
BignumTest:test_NInt256_middle() (gas: 2134)
9-
BignumTest:test_NInt256_multi() (gas: 1190)
10-
BignumTest:test_NInt256_random(int256) (runs: 256, μ: 5100, ~: 5100)
11-
BignumTest:test_NInt256_single() (gas: 1191)
12-
BignumTest:test_UInt256_max() (gas: 1502)
13-
BignumTest:test_UInt256_middle() (gas: 1946)
14-
BignumTest:test_UInt256_multi() (gas: 1068)
15-
BignumTest:test_UInt256_random(uint256) (runs: 256, μ: 1561, ~: 1561)
16-
BignumTest:test_UInt256_single() (gas: 1364)
17-
BytesTest:test_Bytes32_short() (gas: 802)
18-
BytesTest:test_Bytes_empty() (gas: 761)
19-
BytesTest:test_Bytes_extended() (gas: 851)
20-
BytesTest:test_Bytes_short() (gas: 779)
21-
BytesTest:test_skipBytes() (gas: 653)
22-
CidSha256Test:test_Cid() (gas: 521)
23-
CidSha256Test:test_Cid_multicodec_raw() (gas: 449)
24-
CidSha256Test:test_Cid_random(uint256) (runs: 256, μ: 3520, ~: 3520)
25-
CidSha256Test:test_NullableCid_nullCbor() (gas: 519)
26-
CidSha256Test:test_NullableCid_random(uint256) (runs: 256, μ: 885, ~: 889)
271
ComparisonTest:test_decodeArrayU8_CBORDecoder() (gas: 5274)
282
ComparisonTest:test_decodeArrayU8_ReadCbor() (gas: 2334)
293
ComparisonTest:test_decodeFalse_CBORDecoder() (gas: 916)
@@ -39,76 +13,4 @@ ComparisonTest:test_decodeStringWithWeirdChar_ReadCbor() (gas: 884)
3913
ComparisonTest:test_decodeString_CBORDecoder() (gas: 3869)
4014
ComparisonTest:test_decodeString_ReadCbor() (gas: 957)
4115
ComparisonTest:test_decodeTrue_CBORDecoder() (gas: 937)
42-
ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483)
43-
HeaderTest:test_header() (gas: 651)
44-
HeaderTest:test_header32_u16() (gas: 726)
45-
HeaderTest:test_header32_u32() (gas: 700)
46-
IntTest:test_Int_max() (gas: 835)
47-
IntTest:test_Int_min() (gas: 948)
48-
IntTest:test_Int_neg_one() (gas: 787)
49-
IntTest:test_Int_nint16() (gas: 891)
50-
IntTest:test_Int_uint16() (gas: 778)
51-
IntTest:test_Int_zero() (gas: 695)
52-
MapTest:test_Map_empty() (gas: 559)
53-
MapTest:test_Map_nested() (gas: 6640)
54-
MapTest:test_Map_nested2() (gas: 3561)
55-
MapTest:test_Map_single() (gas: 1742)
56-
NIntTest:test_NInt() (gas: 874)
57-
NIntTest:test_NInt16() (gas: 874)
58-
NIntTest:test_NInt32() (gas: 947)
59-
NIntTest:test_NInt64() (gas: 938)
60-
NIntTest:test_NInt8_0() (gas: 731)
61-
NIntTest:test_NInt8_1() (gas: 666)
62-
NIntTest:test_NInt8_long() (gas: 789)
63-
NIntTest:test_NInt8_max() (gas: 766)
64-
NIntTest:test_NInt8_short() (gas: 667)
65-
PeekTest:test_isArray_false() (gas: 317)
66-
PeekTest:test_isArray_true() (gas: 312)
67-
PeekTest:test_isBool_false() (gas: 305)
68-
PeekTest:test_isBool_true() (gas: 364)
69-
PeekTest:test_isBytes_false() (gas: 348)
70-
PeekTest:test_isBytes_true() (gas: 311)
71-
PeekTest:test_isInt_false() (gas: 326)
72-
PeekTest:test_isInt_true() (gas: 488)
73-
PeekTest:test_isMap_false() (gas: 304)
74-
PeekTest:test_isMap_true() (gas: 334)
75-
PeekTest:test_isNInt_false() (gas: 353)
76-
PeekTest:test_isNInt_true() (gas: 312)
77-
PeekTest:test_isNull_false() (gas: 376)
78-
PeekTest:test_isNull_true() (gas: 334)
79-
PeekTest:test_isString_false() (gas: 328)
80-
PeekTest:test_isString_true() (gas: 313)
81-
PeekTest:test_isTag_expect_badminor() (gas: 858)
82-
PeekTest:test_isTag_expect_false() (gas: 468)
83-
PeekTest:test_isTag_expect_rand_16(uint16) (runs: 256, μ: 766, ~: 766)
84-
PeekTest:test_isTag_expect_rand_64(uint32) (runs: 256, μ: 777, ~: 777)
85-
PeekTest:test_isTag_expect_rand_64(uint64) (runs: 256, μ: 750, ~: 750)
86-
PeekTest:test_isTag_expect_true() (gas: 459)
87-
PeekTest:test_isTag_false() (gas: 326)
88-
PeekTest:test_isTag_false_expect() (gas: 413)
89-
PeekTest:test_isTag_true() (gas: 333)
90-
PeekTest:test_isUInt_false() (gas: 349)
91-
PeekTest:test_isUInt_true() (gas: 370)
92-
PeekTest:test_isUndefined_false() (gas: 375)
93-
PeekTest:test_isUndefined_true() (gas: 303)
94-
SimpleTest:test_Boolean_false() (gas: 446)
95-
SimpleTest:test_Boolean_true() (gas: 482)
96-
SimpleTest:test_skipNull() (gas: 412)
97-
SimpleTest:test_skipUndefined() (gas: 433)
98-
StringTest:test_String1() (gas: 457)
99-
StringTest:test_String32_short() (gas: 849)
100-
StringTest:test_String_empty() (gas: 755)
101-
StringTest:test_String_extended() (gas: 799)
102-
StringTest:test_String_short() (gas: 778)
103-
StringTest:test_skipString() (gas: 654)
104-
TagTest:test_Tag() (gas: 644)
105-
TagTest:test_Tag_expected() (gas: 671)
106-
UIntTest:test_UInt() (gas: 726)
107-
UIntTest:test_UInt16_max() (gas: 752)
108-
UIntTest:test_UInt32_max() (gas: 790)
109-
UIntTest:test_UInt64_max() (gas: 805)
110-
UIntTest:test_UInt8_0() (gas: 579)
111-
UIntTest:test_UInt8_1() (gas: 577)
112-
UIntTest:test_UInt8_extended() (gas: 657)
113-
UIntTest:test_UInt8_max() (gas: 679)
114-
UIntTest:test_UInt8_short() (gas: 533)
16+
ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483)

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ jobs:
4646

4747
- name: Run snapshot
4848
run: |
49-
forge snapshot --match-test test_ --check
49+
forge snapshot --match-path "test/comparison/*" --check
5050
id: test-committed

foundry.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ libs = ["lib"]
55
optimize = true
66
optimizer_runs = 1000000
77

8+
[profile.test-no-ir]
9+
via-ir = false
10+
11+
[profile.test-via-ir]
12+
via-ir = true
13+
814
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
915

1016
[fmt]

snapshots/ArrayTest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"Array_empty": "235",
3+
"Array_large": "235",
4+
"Array_mixed": "1722",
5+
"Array_nested": "1960",
6+
"Array_single": "628"
7+
}

snapshots/BignumTest.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Integer": "235",
3+
"NInt256_max": "914",
4+
"NInt256_middle": "235",
5+
"NInt256_multi": "816",
6+
"NInt256_single": "816",
7+
"UInt256_max": "770",
8+
"UInt256_middle": "672",
9+
"UInt256_multi": "672",
10+
"UInt256_single": "672"
11+
}

snapshots/BytesTest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"Bytes32_short": "422",
3+
"Bytes_empty": "408",
4+
"Bytes_extended": "497",
5+
"Bytes_short": "445",
6+
"skipBytes": "306"
7+
}

snapshots/CidSha256Test.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Cid": "251",
3+
"Cid_multicodec_raw": "202",
4+
"NullableCid_nullCbor": "198"
5+
}

snapshots/IntTest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Int_max": "495",
3+
"Int_min": "630",
4+
"Int_neg_one": "1111",
5+
"Int_nint16": "572",
6+
"Int_uint16": "437",
7+
"Int_zero": "358"
8+
}

snapshots/MapTest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"Map_empty": "249",
3+
"Map_nested": "6269",
4+
"Map_nested2": "3236",
5+
"Map_single": "1437"
6+
}

snapshots/NIntTest.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"NInt": "556",
3+
"NInt16": "536",
4+
"NInt32": "565",
5+
"NInt64": "600",
6+
"NInt8_0": "332",
7+
"NInt8_1": "332",
8+
"NInt8_long": "431",
9+
"NInt8_max": "430",
10+
"NInt8_short": "333"
11+
}

0 commit comments

Comments
 (0)