📜 ⬆️ ⬇️

Comparing Serializable and Parcelable. In seconds

In this post will be the numbers that the user gubber wanted to know, publishing an article-question Serializable or Parcelable?
The test chart looks like this.


On the X axis - the number of objects sent to the new Activity; Y-axis, obviously, time in seconds.
What was used :
Android 4.2 emulator
Sources

How tests were conducted
The code put the desired type of object. The program was launched and the “warm-up” test for 0 elements was executed. Further, the sets of elements (5, 10, 20, 50, 100, 200, 400, 800, 1000, 1200) were tested. 1200 always went to bed (Transaction is too large). At the same time, the worst data conversion time was recorded.

About objects
Objects are quite simple, consisting of 5 class variables. Four variables are the base type (String, int, float, bool), one of the variables was a list of strings. All data were randomly generated.
For testing, Serializable objects were placed in an ArrayList, and for testing Parcelable, in a simple array.
')
Conclusion
On the basis of tests, it was concluded that Parcelable runs faster on such data than Serializable by an average of 16 times.
Serializable technique is convenient, but can only be used for a small amount of data.

Source: https://habr.com/ru/post/174015/


All Articles