File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -255,3 +255,51 @@ func TestSliceOfStructWithStruct(t *testing.T) {
255255 }
256256
257257}
258+
259+ func BenchmarkEncodeStructI1 (b * testing.B ) {
260+ type Struct struct {
261+ I int64
262+ }
263+ s := Struct {I : 1024 }
264+ buf := new (bytes.Buffer )
265+
266+ b .ResetTimer ()
267+ for i := 0 ; i < b .N ; i ++ {
268+ enc := NewEncoder (buf )
269+ _ = enc .Encode (& s )
270+ }
271+
272+ }
273+
274+ func BenchmarkEncodeStructI2 (b * testing.B ) {
275+ type Struct struct {
276+ I int64
277+ }
278+ s := Struct {I : 1024 }
279+ buf := new (bytes.Buffer )
280+ enc := NewEncoder (buf )
281+
282+ b .ResetTimer ()
283+ for i := 0 ; i < b .N ; i ++ {
284+ _ = enc .Encode (& s )
285+ }
286+
287+ }
288+
289+ func BenchmarkEncodeStructI3 (b * testing.B ) {
290+ type Struct struct {
291+ I int64
292+ }
293+ s := Struct {I : 1024 }
294+ buf := new (bytes.Buffer )
295+ enc := NewEncoder (buf )
296+
297+ b .ResetTimer ()
298+ for i := 0 ; i < b .N ; i ++ {
299+ err := enc .Encode (& s )
300+ if err != nil {
301+ b .Fatalf ("error: %v\n " , err )
302+ }
303+ }
304+
305+ }
You can’t perform that action at this time.
0 commit comments