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 a .MarshalJSONBuf interface to reduce bytes.Buffer allocations #3

Merged
merged 1 commit into from Mar 29, 2014

Conversation

Projects
None yet
1 participant
@pquerna
Owner

pquerna commented Mar 29, 2014

Adds a new interface, MarshalJSONBuf which takes a bytes.Buffer as a parameter, instead of returning []bytes.

This is about ~16% faster on my laptop for the goser Log structure.

BenchmarkFFMarshalJSON    200000         10164 ns/op      60.60 MB/s        4227 B/op         46 allocs/op
BenchmarkFFMarshalJSONBuf     200000          8697 ns/op      70.83 MB/s        1959 B/op         42 allocs/op
Add a .MarshalJSONBuf interface to the generated code, so for structs…
… containing other ffjson structs, we can avoid having to allocate multiple bytes.Buffers

pquerna added a commit that referenced this pull request Mar 29, 2014

Merge pull request #3 from pquerna/shared_buffer_interface
Add a .MarshalJSONBuf interface to reduce bytes.Buffer allocations

@pquerna pquerna merged commit 8f7f4f7 into master Mar 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment