![]() This is because I couldn’t otherwise find a way to use the standard library with Retrofit without my compiler giving me an error for duplicated modules. I want to stress that in my gradle implementation for adding Kotlinx Serialization, I’m only using this: implementation ":retrofit2-kotlinx-serialization-converter:0.5.0" If you want to see the comparisons, I recommend you check out that post too. I’ll be following the same tests as I did with the previous 3 parsers so we can compare these Kotlin-based parsers with them. I also run a dummy test for each of the parsers to minimise the factor of any first-use-startup time affecting our tests. ![]() To avoid having the JVM startup time be a factor, I have one dummy test that runs before any of the actual tests. This class will of course be slightly varied between their Jackson and Kotlinx counterparts, but they all achieve the bare syntax needed to parse a post from the above API. The short one has 14 lines of JSON code, the medium one has 602, and the long one has 10106. ![]() I also have 3 different JSON responses saved, all lists of the JsonPlaceholder Posts of varying lengths. I have 3 Retrofit interfaces set up, one for each parser. I’ll be running each of these tests at least twice to make sure there aren’t any flukes.ĭo note that this benchmarking test will only cover deserialisation JSON responses into Java (or well actually, Kotlin) objects and not the other way around. We’ll be running the tests on the JVM and using MockWebServer to return responses of different lengths and we’ll have them returned as RxJava Singles. ![]() Putting that against Kotlinx Serialization, a parser that boasts superpowers over the other parsers because it was build with and for Kotlin.Įach test is going to be done within the context of Retrofit because that’s how most apps make network calls nowadays. We’re introducing Jackson again but this time, with its Kotlin module. I recommend giving that a read too.īut this time, due to popular demand on Reddit, it’s all about the Kotlin modules. Last time, we put Gson, Jackson, and Moshi to the test. We’ll take different JSON Parsers, run them through tests, run them once, run them ten times, run them a thousand times, look at their speeds, and infer the reasons behind why one might be faster in certain situations. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |