Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EachRawKey function #250

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

johnzhanghua
Copy link

Description: What this PR does
Ge the raw json value by key(s)

Benchmark before change:

go test  -test.benchmem -bench JsonParser  -benchtime 5s -v 
goos: darwin
goarch: amd64
pkg: benchmarks
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkJsonParserLarge
BenchmarkJsonParserLarge-12                               121890             48241 ns/op               0 B/op          0 allocs/op
BenchmarkJsonParserMedium
BenchmarkJsonParserMedium-12                              737367              7929 ns/op               0 B/op          0 allocs/op
BenchmarkJsonParserDeleteMedium
BenchmarkJsonParserDeleteMedium-12                        644487              8265 ns/op               0 B/op          0 allocs/op
BenchmarkJsonParserEachKeyManualMedium
BenchmarkJsonParserEachKeyManualMedium-12                1397266              5250 ns/op             112 B/op          2 allocs/op
BenchmarkJsonParserEachKeyStructMedium
BenchmarkJsonParserEachKeyStructMedium-12                1162446              4698 ns/op             512 B/op         12 allocs/op
BenchmarkJsonParserObjectEachStructMedium
BenchmarkJsonParserObjectEachStructMedium-12              765534              8272 ns/op             464 B/op         11 allocs/op
BenchmarkJsonParserSmall
BenchmarkJsonParserSmall-12                              8205598               900.3 ns/op             0 B/op          0 allocs/op
BenchmarkJsonParserEachKeyManualSmall
BenchmarkJsonParserEachKeyManualSmall-12                11199094               630.0 ns/op            80 B/op          2 allocs/op
BenchmarkJsonParserEachKeyStructSmall
BenchmarkJsonParserEachKeyStructSmall-12                 9957225               637.5 ns/op           144 B/op          4 allocs/op
BenchmarkJsonParserObjectEachStructSmall
BenchmarkJsonParserObjectEachStructSmall-12             12719120               524.5 ns/op           128 B/op          3 allocs/op
BenchmarkJsonParserSetSmall
BenchmarkJsonParserSetSmall-12                           4382893              1190 ns/op             768 B/op          4 allocs/op
BenchmarkJsonParserDelSmall
BenchmarkJsonParserDelSmall-12                           4771620              1238 ns/op               0 B/op          0 allocs/op
PASS
ok      benchmarks      99.522s

Benchmark after change:

goos: darwin
goarch: amd64
pkg: benchmarks
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkJsonParserLarge
BenchmarkJsonParserLarge-12                               118378             48678 ns/op               0 B/op          0 allocs/op
BenchmarkJsonParserMedium
BenchmarkJsonParserMedium-12                              633284              9046 ns/op               0 B/op          0 allocs/op
BenchmarkJsonParserDeleteMedium
BenchmarkJsonParserDeleteMedium-12                        531616             10205 ns/op               0 B/op          0 allocs/op
BenchmarkJsonParserEachKeyManualMedium
BenchmarkJsonParserEachKeyManualMedium-12                1342858              4326 ns/op             112 B/op          2 allocs/op
BenchmarkJsonParserEachKeyStructMedium
BenchmarkJsonParserEachKeyStructMedium-12                1245860              5343 ns/op             512 B/op         12 allocs/op
BenchmarkJsonParserObjectEachStructMedium
BenchmarkJsonParserObjectEachStructMedium-12              682888              7571 ns/op             464 B/op         11 allocs/op
BenchmarkJsonParserSmall
BenchmarkJsonParserSmall-12                              8599874               765.5 ns/op             0 B/op          0 allocs/op
BenchmarkJsonParserEachKeyManualSmall
BenchmarkJsonParserEachKeyManualSmall-12                11485190               512.3 ns/op            80 B/op          2 allocs/op
BenchmarkJsonParserEachKeyStructSmall
BenchmarkJsonParserEachKeyStructSmall-12                 9590974               590.9 ns/op           144 B/op          4 allocs/op
BenchmarkJsonParserObjectEachStructSmall
BenchmarkJsonParserObjectEachStructSmall-12             10978040               462.6 ns/op           128 B/op          3 allocs/op
BenchmarkJsonParserSetSmall
BenchmarkJsonParserSetSmall-12                           6319124               961.1 ns/op           768 B/op          4 allocs/op
BenchmarkJsonParserDelSmall
BenchmarkJsonParserDelSmall-12                           4887424              1221 ns/op               0 B/op          0 allocs/op
PASS
ok      benchmarks      85.056s

@johnzhanghua johnzhanghua marked this pull request as ready for review August 18, 2022 06:16
@johnzhanghua johnzhanghua changed the title Add each raw key Add EachRawKey function Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants