Comparison of Serializable and Parcelable. In seconds

    Will there be numbers in this post that the gubber user wanted to know when publishing a Serializable or Parcelable question article?
    The test graph is as follows:


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

    How tests were carried out
    In the code, the desired type of object was set. The program was launched and a “warm-up” test was run for 0 elements. Further, sets of elements were tested (5, 10, 20, 50, 100, 200, 400, 800, 1000, 1200). 1200 always went down (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 was randomly generated.
    For testing, Serializable objects were placed in an ArrayList, and for testing Parcelable in a simple array.

    Conclusion
    Based on the tests, it was concluded that Parcelable is faster on such data than Serializable on average 16 times.
    The Serializable technique is convenient, but can only be used for a small amount of data.

    Also popular now: