I did a little experiment ( source ) in the memory and operating time of an array of cells, containers. Map and heterogeneous array. In my method, I pre-allocated each array with N = 65535 elements (the maximum array size for the Map and Heterogenic array), then began to assign uint32 to each element and measure time and memory. My heterogeneous class was a simple class with a single public property and the constructor that assigned this property. There were uint32 key / value pairs in the .Map containers.
Maps took 9.17917e-01 seconds. Cells took 5.81220e-02 seconds. Heterogeneous array took 4.95336e+00 seconds. **Name** **Size** **Bytes** **Class** map 65535x1 112 containers.Map cellArr 65535x1 7602060 cell hArr 1x65535 262244 SomeHeterogeneousClass
Note immediately that the size of mapArray is inaccurate. It is hidden behind the implementation of the container.Map class, most of which corresponds to 112 bytes, this is the memory assigned to the card itself, with the exception of data. I approximate the true size to at least (112 + 65535 * (sizeof (uint32) * 2)) = 524392 bytes. This value is almost twice the size of hArr, which makes me think that it is pretty accurate, since the card should store twice as much data (for the value of the AND key) as hArr.
The results are simple:
- Time: array of cells <Map <Heterogeneous array
- Memory: heterogeneous array <Map <array of cells
I repeated the experiment with N = 30 to test small arrays, the results were similar. God knows why cells take up so much memory, and heterogeneous arrays are so slow.
source share