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

Request For Comments: How about annotation processing? #807

Closed
gfx opened this issue Mar 6, 2016 · 6 comments
Closed

Request For Comments: How about annotation processing? #807

gfx opened this issue Mar 6, 2016 · 6 comments

Comments

@gfx
Copy link

gfx commented Mar 6, 2016

I'm writing a Gson extension, which uses annotation processing to generate type adapter factories:

This is faster than the reflection based adapters which gson has. In fact, even faster than Moshi.

And here is a question: should I develop this extension as a standalone library? Or should I make a pull-request to Gson as a processor module?

P.S. here is a benchmark result. "dynamic gson" is the original reflection based with Gson 2.6.2, "static gson" is StaticGson, and moshi is Moshi v1.1.0:

D/XXX : start benchmarking dynamic gson
D/XXX : dynamic gson in serialization: 318ms
D/XXX : dynamic gson in deserialization: 298ms

D/XXX : start benchmarking static gson
D/XXX : static gson in serialization: 141ms
D/XXX : static gson in deserialization: 177ms

D/XXX : start benchmarking moshi
D/XXX : moshi in serialization: 204ms
D/XXX : moshi in deserialization: 449ms
@swankjesse
Copy link
Collaborator

Sounds similar to Logan Square. My preference is as a standalone project.

@gfx
Copy link
Author

gfx commented Mar 6, 2016

I will developing this project as a standalone. Thanks.

BTW, Logan Square is great. It seems fastest in serialization.

Interestingly, however, static gson is faster than Logan Square in deserialization.

Added LoganSquare benchmark to the StaticGson with the same JSON data:

D/XXX: start benchmarking LoganSquare
D/XXX: LoganSquare in serialization: 82ms
D/XXX: LoganSquare in deserialization: 243ms

@inder123
Copy link
Collaborator

inder123 commented Mar 6, 2016

@gfx Yes, makes sense to develop as a standalone project, and as it matures, we can consider borrowing some features in Gson core.

Great idea, BTW. I wasn't familiar with Logan Square either. Looking forward to more documentation/tutorial on your project page and trying it out.

@LachlanMcKee
Copy link

@gfx Wow, this is pretty crazy timing. I was looking for a project that did this over a week ago.

Since you hadn't posted this at the time, I have also started working on a very similar project:

My project generates type adapters as well. I have also added a very basic json path generator as part of the project.

e.g. "Parent.Child" would create nested loops within the type adapter which can help flatten the POJO

Did you have any plans to implement something similar? Or is the main focus to keep it fairly simplistic?

@gfx
Copy link
Author

gfx commented Mar 12, 2016

@LachlanM OMG. If I knew your project, I wouldn't make Static Gson. lol.

JSON path style seems interesting although I didn't have a plan yet. My first aim is to use Static Gson in my projects with least effort. JSON path will be the second milestone.

@gfx
Copy link
Author

gfx commented Mar 20, 2016

StaticGson starts is released as an independent artifact: https://bintray.com/gfx/maven/static-gson/

Thanks.

@gfx gfx closed this as completed Mar 20, 2016
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

No branches or pull requests

4 participants