-
Notifications
You must be signed in to change notification settings - Fork 0
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
Avoid too many copies in string encoder/decoder #33
Conversation
21e8ebe
to
d1122a4
Compare
@dshulyak I got the following results running the benchmarks in
I'm not sure if we should use the unsafe variants avoiding additional allocations, the go runtime will try to avoid allocations anyway if it can. In the case of Bytes2String we are ~ 30% faster, but in the case of String2Bytes we are ~ 20% slower than the safe way to do it. What is your opinion? PS.: Results with optimization:
I'm not sure how accurate this is, the go compiler/runtime might just completely optimize the benchmark away. Either way according to the Benchmark all versions with and without optimizations trigger 0 allocations per operation. |
Using a
without optimization there is almost no difference:
|
I updated the benchmarks in a way that hopefully prevents go from optimizing the allocation away. These are the new results:
|
db3a9a9
to
d76279f
Compare
Closes #12