While investigating a performance difference between Vector and FixedSizeVector, I discovered that there was also a performance difference between map, broadcast and for/loops.
I am not 100% sure that all implementations are equivalent, but I made my best effort.
From the table below you can see that for simple calls stock Vectors perform equally except if the is a do block, but are a mixed bag for FixedSizeVectors
For more complicated things it is a mixed bag and for the full case that I am interested clearly a for/loop behaves differently between Vector and FixedSizeVector. At least on my computer.
With Vector
| ID |
time |
GC time |
memory |
allocations |
["Full", "Generated", "Vector"] |
971.000 ns (5%) |
|
|
|
["Non-Simple", "Broadcast", "Vector"] |
5.570 μs (5%) |
|
|
|
["Non-Simple", "Loop", "Vector"] |
991.000 ns (5%) |
|
|
|
["Non-Simple", "Map", "Vector"] |
5.621 μs (5%) |
|
|
|
["Simple", "Broadcast", "Vector"] |
641.000 ns (5%) |
|
|
|
["Simple", "Loop", "Vector"] |
641.000 ns (5%) |
|
|
|
["Simple", "Map Do", "Vector"] |
3.937 μs (5%) |
|
|
|
["Simple", "Map", "Vector"] |
641.000 ns (5%) |
|
|
|
With FixedSizeVector
| ID |
time |
GC time |
memory |
allocations |
["Full", "Generated", "FixedSizeVector"] |
5.370 μs (5%) |
|
|
|
["Non-Simple", "Broadcast", "FixedSizeVector"] |
6.051 μs (5%) |
|
|
|
["Non-Simple", "Loop", "FixedSizeVector"] |
5.019 μs (5%) |
|
|
|
["Non-Simple", "Map", "FixedSizeVector"] |
6.001 μs (5%) |
|
|
|
["Simple", "Broadcast", "FixedSizeVector"] |
641.000 ns (5%) |
|
|
|
["Simple", "Loop", "FixedSizeVector"] |
3.536 μs (5%) |
|
|
|
["Simple", "Map Do", "FixedSizeVector"] |
3.917 μs (5%) |
|
|
|
["Simple", "Map", "FixedSizeVector"] |
641.000 ns (5%) |
|
|
|
I include an MWE to replicate these results.
MWESLEEFPiratesNFSA.tar.gz
While investigating a performance difference between
VectorandFixedSizeVector, I discovered that there was also a performance difference betweenmap,broadcastandfor/loops.I am not 100% sure that all implementations are equivalent, but I made my best effort.
From the table below you can see that for simple calls stock
Vectorsperform equally except if the is adoblock, but are a mixed bag forFixedSizeVectorsFor more complicated things it is a mixed bag and for the full case that I am interested clearly a
for/loopbehaves differently betweenVectorandFixedSizeVector. At least on my computer.With
Vector["Full", "Generated", "Vector"]["Non-Simple", "Broadcast", "Vector"]["Non-Simple", "Loop", "Vector"]["Non-Simple", "Map", "Vector"]["Simple", "Broadcast", "Vector"]["Simple", "Loop", "Vector"]["Simple", "Map Do", "Vector"]["Simple", "Map", "Vector"]With
FixedSizeVector["Full", "Generated", "FixedSizeVector"]["Non-Simple", "Broadcast", "FixedSizeVector"]["Non-Simple", "Loop", "FixedSizeVector"]["Non-Simple", "Map", "FixedSizeVector"]["Simple", "Broadcast", "FixedSizeVector"]["Simple", "Loop", "FixedSizeVector"]["Simple", "Map Do", "FixedSizeVector"]["Simple", "Map", "FixedSizeVector"]I include an MWE to replicate these results.
MWESLEEFPiratesNFSA.tar.gz