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

Change ArrayEach CB Signature to Return Error #156

Closed
wants to merge 1 commit into from

Conversation

jlhawn
Copy link

@jlhawn jlhawn commented Nov 13, 2018

Description: Changes the callback function signature of ArrayEach to return an error. It currently takes an error as input even though ArrayEach never passes a non-nil error into it. It should be more like ObjectEach which returns an error from its callback function.

I had to fix Dockerfile and benchmark/benchmark_codecgen.go in order to get benchmarks to run.

(...it makes this repository seem very under-maintained).

Benchmark before change: DID NOT WORK

Benchmark after change:

$ make bench
docker run -v `pwd`:/go/src/github.com/buger/jsonparser -i -t jsonparser go test  -test.benchmem -bench JsonParser ./benchmark/  -benchtime 5s -v
goos: linux
goarch: amd64
pkg: github.com/buger/jsonparser/benchmark
BenchmarkJsonParserLarge-4                    	  100000	     65332 ns/op	       0 B/op	       0 allocs/op
BenchmarkJsonParserMedium-4                   	 1000000	      9871 ns/op	       0 B/op	       0 allocs/op
BenchmarkJsonParserDeleteMedium-4             	 1000000	     10448 ns/op	       0 B/op	       0 allocs/op
BenchmarkJsonParserEachKeyManualMedium-4      	 1000000	      6816 ns/op	     112 B/op	       2 allocs/op
BenchmarkJsonParserEachKeyStructMedium-4      	 1000000	      7636 ns/op	     672 B/op	      12 allocs/op
BenchmarkJsonParserObjectEachStructMedium-4   	 1000000	     10229 ns/op	     624 B/op	      11 allocs/op
BenchmarkJsonParserSmall-4                    	10000000	      1081 ns/op	       0 B/op	       0 allocs/op
BenchmarkJsonParserEachKeyManualSmall-4       	10000000	       810 ns/op	      80 B/op	       2 allocs/op
BenchmarkJsonParserEachKeyStructSmall-4       	10000000	       935 ns/op	     144 B/op	       4 allocs/op
BenchmarkJsonParserObjectEachStructSmall-4    	10000000	       815 ns/op	     128 B/op	       3 allocs/op
BenchmarkJsonParserSetSmall-4                 	 5000000	      1593 ns/op	     816 B/op	       5 allocs/op
BenchmarkJsonParserDelSmall-4                 	 5000000	      1889 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/buger/jsonparser/benchmark	113.794s

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
@vanackere
Copy link

@buger : I was in the process of writing the exact same pull request when I noticed this was already there... Any chance to have this merged ?

@jlhawn jlhawn closed this Nov 8, 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.

None yet

2 participants