Haxe & NME Collections Benchmark

06.10.2012 2364 0

		iterations	FP 11.4	    FP 11.4	HTML5      Windows    Android
				Debug	    Release
    writing 
Array 		x 1000000	: 140	    : 61	: 159      : 12	      : 183
Vector 		x 1000000	: 161	    : 75	: 115      : 29	      : 173
fixed Vector*	x 1000000	: 9	    : 7		                           
List 		x 1000000	: 437	    : 299	: 348      : 2775     : 21230
FastList 	x 1000000	: 427	    : 279	: 516      : 26	      : 192
ByteArray 	x 1000000	: 104	    : 52	           : 33	      : 222
Memory*		x 1000000	: 10	    : 7		           : 2	      : 9
    reading 
Array 		x 1000000	: 70	    : 12	: 7        : 0	      : 0
Vector 		x 1000000	: 12	    : 9		: 9        : 0	      : 0
fixed Vector*	x 1000000	: 12	    : 9		                           
List 		x 1000000	: 532	    : 428	: 632      : 622      : 5024
FastList 	x 1000000	: 12	    : 8		: 506      : 3	      : 55
ByteArray 	x 1000000	: 144	    : 17	           : 14	      : 150
Memory*		x 1000000	: 8	    : 6		           : 1	      : 0
    removing 
Array 		x 100000	: 8069	    : 7936	: 5203     : 2601     : 16084
Vector 		x 100000 	: 2826	    : 2763	: 5219     : 2612     : 16141
List 		x 100000 	: 60	    : 45	: 105      : 18	      : 194
FastList 	x 100000 	: 9	    : 4		: 113      : 1	      : 8

* Fixed length's Vector, only available on Flash has almost the same performance as Memory (removed for content targeting Flash Player 11 since Flash plaver 11.2). But you have to work in "fixed mode" : you can't remove elements.

Depending on what you're working on, you need different kind of collection. For exemple you won't use the same container if you're updating the position of a sprite displayed on the screen and remove it if it's over the bounds, as if you want to update pixels of a given bitmapData or manipulate another stream. Of course, you can otpimize a bit by mixing collections but seeing the results of my basic test we can yet notice some details :

  • When manipulating streams fixed collections will be better like Memory (if available), fixed Vector (if available), ByteArray, Array and Vector should be used in this order to get best performances. Note that FastList has pretty good performances and is often faster than ByteArray.
  • When manipulating objects it seems that FastList is the best choice. Then depending on if you need to remove elements from the collection, List comes next. Working in "fixed mode", Vector and Array will be better choices.
  • FastList seems to be a really good choice in many cases and is available on all plateforms.

Here you can see and download the sources
Or see your personal results on Flash Player:

Commentaires

Laisser un commentaire

http://
×