@@ -48,7 +48,7 @@ func TestBestMemJSONEfficiency(t *testing.T) {
48
48
}
49
49
})
50
50
51
- bestmemResult := testing .Benchmark (func (b * testing.B ) {
51
+ bestMemResult := testing .Benchmark (func (b * testing.B ) {
52
52
b .ResetTimer ()
53
53
b .ReportAllocs ()
54
54
for i := 0 ; i < b .N ; i ++ {
@@ -65,18 +65,18 @@ func TestBestMemJSONEfficiency(t *testing.T) {
65
65
standardResult .AllocsPerOp (),
66
66
jsoniterResult .AllocedBytesPerOp (),
67
67
jsoniterResult .AllocsPerOp (),
68
- bestmemResult .AllocedBytesPerOp (),
69
- bestmemResult .AllocsPerOp ())
68
+ bestMemResult .AllocedBytesPerOp (),
69
+ bestMemResult .AllocsPerOp ())
70
70
71
71
// Verify bestmemjson is using the most memory-efficient implementation
72
- assert .LessOrEqual (t , bestmemResult .AllocedBytesPerOp (), standardResult .AllocedBytesPerOp (),
72
+ assert .LessOrEqual (t , bestMemResult .AllocedBytesPerOp (), standardResult .AllocedBytesPerOp (),
73
73
"bestmemjson.Marshal should not use more memory than encoding/json.Marshal" )
74
- assert .LessOrEqual (t , bestmemResult .AllocedBytesPerOp (), jsoniterResult .AllocedBytesPerOp (),
74
+ assert .LessOrEqual (t , bestMemResult .AllocedBytesPerOp (), jsoniterResult .AllocedBytesPerOp (),
75
75
"bestmemjson.Marshal should not use more memory than jsoniter.Marshal" )
76
76
})
77
77
78
78
t .Run ("Unmarshal memory efficiency" , func (t * testing.T ) {
79
- var standardModel , jsoniterModel , bestmemModel testStruct
79
+ var standardModel , jsoniterModel , bestMemModel testStruct
80
80
81
81
standardResult := testing .Benchmark (func (b * testing.B ) {
82
82
b .ResetTimer ()
@@ -94,11 +94,11 @@ func TestBestMemJSONEfficiency(t *testing.T) {
94
94
}
95
95
})
96
96
97
- bestmemResult := testing .Benchmark (func (b * testing.B ) {
97
+ bestMemResult := testing .Benchmark (func (b * testing.B ) {
98
98
b .ResetTimer ()
99
99
b .ReportAllocs ()
100
100
for i := 0 ; i < b .N ; i ++ {
101
- _ = Unmarshal (testJSON , & bestmemModel )
101
+ _ = Unmarshal (testJSON , & bestMemModel )
102
102
}
103
103
})
104
104
@@ -111,17 +111,17 @@ func TestBestMemJSONEfficiency(t *testing.T) {
111
111
standardResult .AllocsPerOp (),
112
112
jsoniterResult .AllocedBytesPerOp (),
113
113
jsoniterResult .AllocsPerOp (),
114
- bestmemResult .AllocedBytesPerOp (),
115
- bestmemResult .AllocsPerOp ())
114
+ bestMemResult .AllocedBytesPerOp (),
115
+ bestMemResult .AllocsPerOp ())
116
116
117
117
// Verify bestmemjson is using the most memory-efficient implementation
118
- assert .LessOrEqual (t , bestmemResult .AllocedBytesPerOp (), standardResult .AllocedBytesPerOp (),
118
+ assert .LessOrEqual (t , bestMemResult .AllocedBytesPerOp (), standardResult .AllocedBytesPerOp (),
119
119
"bestmemjson.Unmarshal should not use more memory than encoding/json.Unmarshal" )
120
- assert .LessOrEqual (t , bestmemResult .AllocedBytesPerOp (), jsoniterResult .AllocedBytesPerOp (),
120
+ assert .LessOrEqual (t , bestMemResult .AllocedBytesPerOp (), jsoniterResult .AllocedBytesPerOp (),
121
121
"bestmemjson.Unmarshal should not use more memory than jsoniter.Unmarshal" )
122
122
123
123
// Verify all implementations produce the same result
124
- assert .Equal (t , standardModel , bestmemModel , "bestmemjson.Unmarshal should produce same result as encoding/json" )
125
- assert .Equal (t , jsoniterModel , bestmemModel , "bestmemjson.Unmarshal should produce same result as jsoniter" )
124
+ assert .Equal (t , standardModel , bestMemModel , "bestmemjson.Unmarshal should produce same result as encoding/json" )
125
+ assert .Equal (t , jsoniterModel , bestMemModel , "bestmemjson.Unmarshal should produce same result as jsoniter" )
126
126
})
127
127
}
0 commit comments