android - Is writting parcelable objects in a bundle that fast? -
i wanted estimate time needed write parcelable object in bundle. created own parcelable class (with 2 attributs : int , string) , wrote short application instanciates 500 000 objects of parcelable class, puts them arraylist, writes arraylist in bundle, , reads arraylist same bundle.
i surprised see writting , reading quite huge list instantaneaous. (0ms every time)
can such arraylist written "instantaneously", or doing wrong ?
i grateful can provide.
... private static final int test_size = 500000; ... mlist = new arraylist<myparcelableclass>(); for(int i=0; i<test_size; i++){ mlist.add(new myparcelableclass(i)); } ... bundle testbundle = new bundle(); mstarttime = system.currenttimemillis(); testbundle.putparcelablearraylist("test", mlist); logtime("parcelablearraylist writting"); //parcelablearraylist writting 0ms arraylist<myparcelableclass> deserialization = new arraylist<myparcelableclass>(); mstarttime = system.currenttimemillis(); deserialization = testbundle.getparcelablearraylist("test"); logtime("parcelablearraylist reading"); //parcelablearraylist reading 0ms private void logtime(string msg){ long time = system.currenttimemillis() - mstarttime; log(msg + " " + string.valueof(time) + " ms"); } private void log(string msg){ log.i(tag, msg); }
Comments
Post a Comment