-
Notifications
You must be signed in to change notification settings - Fork 618
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
Performance issue? #89
Comments
Thanks a lot for sharing. We have not looked at the performance yet (as the project was mostly focused on feature-wise exploration of potential design approaches) and it is worth looking indeed. |
I also did some benchmarks, and kotlinx.serialization doesn't look good |
I've investigated |
On the other hand, |
I've improved JSON.parse performance (see #102). Now it is better than
The only reasonable explanation for gson's better performance seems to be in the fact that gson converts input data to |
As a user of this library I welcome improvements to its performance! But for what it's worth, this is a case that neither Gson and especially not Moshi are really optimizing for. We don't consider serialization to/from a String or a character array to be their common usage. Moshi is optimized for streaming to and from bytes and especially so with other libraries that use Okio to move bytes around (i.e., Retrofit and OkHttp). |
I've also optimized
It is still slower than |
As of |
I updated my benchmarks, kotlinx.serialization looks much better now https://github.com/wizzardo/json-benchmarks |
Updated benchmarks here as well: ZacSweers/json-serialization-benchmarking#4 kotlinx serialization has improved, but so has gson (drastically) and moshi. Moshi now also has native kotlin support for both reflection and code gen |
I think this can be closed for now, since kotlinx.serialization is not at the bottom of benchmark :). Of course, improving performance further would still be our concern in future work. |
I'm trying to compare the performance of kotlinx.serialization with Gson and Moshi and I'm finding it significantly slower. Here is a PR with the three being compared using jmh.
The original project comparing just Gson and Moshi is by Zac Sweers. In my PR, I converted the models to Kotlin and added the benchmark for kotlinx.serialization using
JSON.parse()
andJSON.stringify()
.I'm wondering why the performance of kotlinx.serialization is so much lower than the other two. Is there anything I am missing? I would like to investigate this further but not sure where to start. Would appreciate any pointers on where to start looking.
Thanks!
The text was updated successfully, but these errors were encountered: