@@ -7,31 +7,31 @@ import (
7
7
mh "github.com/multiformats/go-multihash"
8
8
)
9
9
10
- type myStruct struct {
11
- items map [string ]myStruct
12
- foo string
13
- bar []byte
14
- baz []int
10
+ type MyStruct struct {
11
+ Items map [string ]MyStruct
12
+ Foo string
13
+ Bar []byte
14
+ Baz []int
15
15
}
16
16
17
17
func init () {
18
- RegisterCborType (myStruct {})
18
+ RegisterCborType (MyStruct {})
19
19
}
20
20
21
- func testStruct () myStruct {
22
- return myStruct {
23
- items : map [string ]myStruct {
24
- "foo " : {
25
- foo : "foo " ,
26
- bar : []byte ("bar " ),
27
- baz : []int {1 , 2 , 3 , 4 },
21
+ func testStruct () MyStruct {
22
+ return MyStruct {
23
+ Items : map [string ]MyStruct {
24
+ "Foo " : {
25
+ Foo : "Foo " ,
26
+ Bar : []byte ("Bar " ),
27
+ Baz : []int {1 , 2 , 3 , 4 },
28
28
},
29
- "bar " : {
30
- bar : []byte ("bar " ),
31
- baz : []int {1 , 2 , 3 , 4 },
29
+ "Bar " : {
30
+ Bar : []byte ("Bar " ),
31
+ Baz : []int {1 , 2 , 3 , 4 },
32
32
},
33
33
},
34
- baz : []int {5 , 1 , 2 },
34
+ Baz : []int {5 , 1 , 2 },
35
35
}
36
36
}
37
37
@@ -102,3 +102,13 @@ func BenchmarkDecodeBlockParallel(b *testing.B) {
102
102
}
103
103
wg .Wait ()
104
104
}
105
+
106
+ func BenchmarkDumpObject (b * testing.B ) {
107
+ obj := testStruct ()
108
+ for i := 0 ; i < b .N ; i ++ {
109
+ bytes , err := DumpObject (obj )
110
+ if err != nil {
111
+ b .Fatal (err , bytes )
112
+ }
113
+ }
114
+ }
0 commit comments