-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark_20fields.go
96 lines (88 loc) · 2.09 KB
/
benchmark_20fields.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package json_benchmark
import (
"encoding/json"
)
var twentyFieldsByte = []byte(`{
"intf": -123,
"uintf": 456,
"stringf": "abc",
"uuidf": "de305d54-75b4-431b-adb2-eb6b9e546014",
"ipf": "127.0.0.1",
"emailf": "[email protected]",
"int32f": -164281,
"uint32f": 2938729,
"int64f": -8973,
"uint64f":89302174,
"intf2": -123,
"uintf2": 456,
"stringf2": "abc",
"uuidf2": "de305d54-75b4-431b-adb2-eb6b9e546014",
"ipf2": "127.0.0.1",
"emailf2": "[email protected]",
"int32f2": -164281,
"uint32f2": 2938729,
"int64f2": -8973,
"uint64f2":89302174
}`)
var twentyFieldsByteMap map[string]interface{}
type twentyFieldsStructWoTag struct {
Intf int
Uintf uint
Stringf string
Uuidf string
Ipf string
Emailf string
Int32f int32
Uint32f uint32
Int64f int64
Uint64f uint64
Intf2 int
Uintf2 uint
Stringf2 string
Uuidf2 string
Ipf2 string
Emailf2 string
Int32f2 int32
Uint32f2 uint32
Int64f2 int64
Uint64f2 uint64
}
var twentyFieldsStructWoTagResult twentyFieldsStructWoTag
type twentyFieldsStructWithTag struct {
Intf int `json:"intf"`
Uintf uint `json:"uintf"`
Stringf string `json:"stringf"`
Uuidf string `json:"uuidf"`
Ipf string `json:"ipf"`
Emailf string `json:"emailf"`
Int32f int32 `json:"int32f"`
Uint32f uint32 `json:"uint32f"`
Int64f int64 `json:"int64f"`
Uint64f uint64 `json:"uint64f"`
Intf2 int `json:"intf2"`
Uintf2 uint `json:"uintf2"`
Stringf2 string `json:"stringf2"`
Uuidf2 string `json:"uuidf2"`
Ipf2 string `json:"ipf2"`
Emailf2 string `json:"emailf2"`
Int32f2 int32 `json:"int32f2"`
Uint32f2 uint32 `json:"uint32f2"`
Int64f2 int64 `json:"int64f2"`
Uint64f2 uint64 `json:"uint64f2"`
}
var twentyFieldsStructWithTagResult twentyFieldsStructWithTag
func init() {
var err error
err = json.Unmarshal(twentyFieldsByte, &twentyFieldsByteMap)
if err != nil {
panic(err)
}
err = json.Unmarshal(twentyFieldsByte, &twentyFieldsStructWoTagResult)
if err != nil {
panic(err)
}
err = json.Unmarshal(twentyFieldsByte, &twentyFieldsStructWithTagResult)
if err != nil {
panic(err)
}
}