-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_test.go
70 lines (64 loc) · 1.64 KB
/
parse_test.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
package json_diff
import (
"fmt"
"github.com/520MianXiangDuiXiang520/json-diff/decode"
`io/ioutil`
"testing"
)
func TestUnmarshal(t *testing.T) {
json2 := `{
"A": 1, "B": [1, 3], "C": [2, 1], "D": 6
}`
node, err := decode.Unmarshal([]byte(json2))
fmt.Println(node, err)
}
func BenchmarkMarshal(b *testing.B) {
fileName := "./test_data/deepcopy_test/deepcopy_speed_test.json"
// fileName := "./test_data/hash_test.json"
input, err := ioutil.ReadFile(fileName)
if err != nil {
b.Error("fail to open the ", fileName)
}
node, _ := decode.Unmarshal(input)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = decode.Marshal(node)
}
}
func BenchmarkMarshalOld(b *testing.B) {
fileName := "./test_data/deepcopy_test/deepcopy_speed_test.json"
// fileName := "./test_data/hash_test.json"
input, err := ioutil.ReadFile(fileName)
if err != nil {
b.Error("fail to open the ", fileName)
}
node, _ := Unmarshal(input)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = Marshal(node)
}
}
func BenchmarkUnmarshal(b *testing.B) {
fileName := "./test_data/deepcopy_test/deepcopy_speed_test.json"
// fileName := "./test_data/hash_test.json"
input, err := ioutil.ReadFile(fileName)
if err != nil {
b.Error("fail to open the ", fileName)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = decode.Unmarshal(input)
}
}
func BenchmarkUnmarshalOld(b *testing.B) {
fileName := "./test_data/deepcopy_test/deepcopy_speed_test.json"
// fileName := "./test_data/hash_test.json"
input, err := ioutil.ReadFile(fileName)
if err != nil {
b.Error("fail to open the ", fileName)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = Unmarshal(input)
}
}