-
Notifications
You must be signed in to change notification settings - Fork 79
Flash Player 9 Container Performance Comparison Table
polygonal edited this page Jul 25, 2012
·
2 revisions
| Container | |||||||||
| Data Types | [1] flash.Vector | [2] Array | [3] Linked List | [4] flash.Memory | flash.utils.ByteArray | ||||
| [5] typed | dynamic | typed | dynamic | [6] managed | [7] unmanaged | ||||
| Byte | - | - | - | - | - | 9 ms | 8 ms | 51 ms | |
| Int | 19 ms | 57 ms | 51 ms | 19 ms | 26 ms | 9 ms | 8 ms | [9] | |
| UInt | 19 ms | 57 ms | 51 ms | 19 ms | 25 ms | 9 ms | 8 ms | [9] | |
| Float | - | - | - | - | - | 9 ms | 8 ms | [9] | |
| Double [8] | 19 ms | 64 ms | 57 ms | 21 ms | 33 ms | 9 ms | 8 ms | [9] | |
| String | 65 ms | 61 ms | 54 ms | 23 ms | 30 ms | - | - | [9] | |
| Bool | 53 ms | 52 ms | 46 ms | 19 ms | 23 ms | - | - | [9] | |
| Object | 70 ms | 64 ms | 58 ms | 24 ms | 33 ms | - | - | - | |
| mean | |||||||||
| 41 ms | 59 ms | 53 ms | 21 ms | 33 ms | 9 ms | 8 ms | 51 ms | ||
[2] built-in flash Array
[3] de.polygonal.ds.DLL (Doubly Linked List)
[4] alchemy memory (FP10.x only)
[5] implements haxe.rtti.Generic
[6] uses de.polygonal.ds.!MemoryManager
[7] optimized loop for computing byte-offsets
[8] equals Number in AS3, Float in !HaXe
[9] Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
Done using a CoreI7 920 CPU, Haxe, Flash Player 10.0.42.34 (release, windows-standalone).
Container size: 1.000.000 elements. All results represent the arithmetic mean over 100 iterations.
Arrayed containers use the standard for loop:
for (i in 0...k)
var value = container[i];Linked containers use:
var node = container.node;
while (node != null)
{
var value = node.value;
node = node.next;
}Conclusions
- Compared to an array, reading non-number types from a vector is ~10% faster, but writing non-number types is ~15-20% slower, so in the end the array wins.
- For number crunching, use flash.Memory (Haxe) or the vector class if flash.Memory isn't available (ActionScript 3.0).
- A linked list still offers the best performance across all data types, but requires more memory.
- Since there is no measurable difference between various loop types (even at this high number of iterations) optimizing the loop itself is the last thing you should consider.