gin
gin copied to clipboard
Optimize the json render
- Merge the write operation for json render and improve the code coverage.
- Reduce convert between
int32
andstring
in theAsciiJSON.Render
function.
Codecov Report
Merging #3091 (9be676c) into master (92dd245) will increase coverage by
0.98%
. The diff coverage is100.00%
.
:exclamation: Current head 9be676c differs from pull request most recent head 501fc1e. Consider uploading reports for the commit 501fc1e to get more accurate results
@@ Coverage Diff @@
## master #3091 +/- ##
==========================================
+ Coverage 98.06% 99.04% +0.98%
==========================================
Files 43 43
Lines 3148 3565 +417
==========================================
+ Hits 3087 3531 +444
+ Misses 48 28 -20
+ Partials 13 6 -7
Flag | Coverage Δ | |
---|---|---|
go-1.14 | 99.25% <100.00%> (?) |
|
go-1.15 | 98.90% <100.00%> (+0.84%) |
:arrow_up: |
go-1.16 | 98.88% <100.00%> (+0.85%) |
:arrow_up: |
go-1.17 | 98.73% <100.00%> (+0.77%) |
:arrow_up: |
go-1.18 | 98.73% <100.00%> (+0.77%) |
:arrow_up: |
macos-latest | 99.04% <100.00%> (+0.98%) |
:arrow_up: |
nomsgpack | 99.03% <100.00%> (+0.99%) |
:arrow_up: |
ubuntu-latest | 99.04% <100.00%> (+0.98%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
render/json.go | 100.00% <100.00%> (+16.85%) |
:arrow_up: |
mode.go | 100.00% <0.00%> (ø) |
|
render/render.go | 100.00% <0.00%> (ø) |
|
binding/header.go | 100.00% <0.00%> (ø) |
|
binding/binding.go | 100.00% <0.00%> (ø) |
|
binding/binding_nomsgpack.go | 100.00% <0.00%> (ø) |
|
gin.go | 99.79% <0.00%> (+0.60%) |
:arrow_up: |
context.go | 98.39% <0.00%> (+1.63%) |
:arrow_up: |
debug.go | 100.00% <0.00%> (+8.33%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 92dd245...501fc1e. Read the comment docs.
@mstmdev Please provide the benchmark result?
@mstmdev Please provide the benchmark result?
The benchmark test result:
Command:
go test -test.v -test.bench . ./render
Environment:
version: go1.18.3
goos: windows
goarch: amd64
pkg: github.com/gin-gonic/gin/render
cpu: Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
The AsciiJSON.Render benchmark result:
BenchmarkAsciiJSONRender(New Pull Request)
BenchmarkAsciiJSONRender-16 657159 1860 ns/op 1194 B/op 20 allocs/op
BenchmarkAsciiJSONRender(Old Master)
BenchmarkAsciiJSONRender-16 493408 2236 ns/op 1076 B/op 20 allocs/op
The JsonpJSON.Render benchmark result:
BenchmarkJsonpJSONRender(New Pull Request)
BenchmarkJsonpJSONRender-16 1312569 982.8 ns/op 884 B/op 10 allocs/op
BenchmarkJsonpJSONRender(Old Master)
BenchmarkJsonpJSONRender-16 1247179 985.2 ns/op 901 B/op 10 allocs/op