-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark_10fields.go
66 lines (58 loc) · 1.32 KB
/
benchmark_10fields.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
package json_benchmark
import (
"encoding/json"
)
var tenFieldsByte = []byte(`{
"intf": -123,
"uintf": 456,
"stringf": "abc",
"uuid": "de305d54-75b4-431b-adb2-eb6b9e546014",
"ip": "127.0.0.1",
"email": "test@example.com",
"int32f": -164281,
"uint32f": 2938729,
"int64f": -8973,
"uint64f": 89302174
}`)
var tenFieldsByteMap map[string]interface{}
type tenFieldsStructWoTag struct {
Intf int
Uintf uint
Stringf string
Uuid string
Ip string
Email string
Int32f int32
Uint32f uint32
Int64f int64
Uint64f uint64
}
var tenFieldsStructWoTagResult tenFieldsStructWoTag
type tenFieldsStructWithTag struct {
Intf int `json:"intf"`
Uintf uint `json:"uintf"`
Stringf string `json:"stringf"`
Uuid string `json:"uuid"`
Ip string `json:"ip"`
Email string `json:"email"`
Int32f int32 `json:"int32f"`
Uint32f uint32 `json:"uint32f"`
Int64f int64 `json:"int64f"`
Uint64f uint64 `json:"uint64f"`
}
var tenFieldsStructWithTagResult tenFieldsStructWithTag
func init() {
var err error
err = json.Unmarshal(tenFieldsByte, &tenFieldsByteMap)
if err != nil {
panic(err)
}
err = json.Unmarshal(tenFieldsByte, &tenFieldsStructWoTagResult)
if err != nil {
panic(err)
}
err = json.Unmarshal(tenFieldsByte, &tenFieldsStructWithTagResult)
if err != nil {
panic(err)
}
}