float[] → Vertex[] – decreases performance by 1000%

Era Scarecrow rtcvb32 at yahoo.com
Tue Jul 24 16:10:38 PDT 2012


On Tuesday, 24 July 2012 at 19:42:34 UTC, David wrote:
>> I agree. I don't know how the CPU handles misaligned floats, 
>> but from
>> what I understand, it will do two loads to fetch the two 
>> word-aligned
>> parts of the float, and then assemble it together. This may be 
>> what's
>> causing the slowdown.
>>
>>
>> T
>>
>
> Remvoing the `align(1)` changes nothing, not 1ms slower or 
> faster, unfortunately.


[quote]
[code]
  Vertex[] data;
  foreach(i; 0..6) {
    data ~= Vertex(positions[i][0], positions[i][1], 
positions[i][2],
[/code]
[/quote]

Try using reserve? The new structure size looks like it's about 
40 bytes, and aside from resizing I'm not sure why it would have 
issues.

[code]
  Vertex[] data;
  data.reserve(6); //following foreach...
[/code]


More information about the Digitalmars-d-learn mailing list