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

Already on GitHub? Sign in to your account

Add a .MarshalJSONBuf interface to reduce bytes.Buffer allocations #3

merged 1 commit into from Mar 29, 2014


None yet
1 participant

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