Slow performance compared to C++, ideas?

Manu turkeyman at gmail.com
Thu May 30 23:41:06 PDT 2013


On 31 May 2013 15:49, finalpatch <fengli at gmail.com> wrote:

> Thanks Nazriel,
>
> It is very cool you are able to narrow the gap to within 1.5x of c++ with
> a few simple changes.
>
> I checked your version, there are 3 changes (correct me if i missed any):
>
> * Change the (float) constructor from v= [x,x,x] to v[0] = x; v[1] = x;
> v[2] = x;
> * Get rid of the (float[]) constructor and use 3 floats instead
> * Change class methods to final
>
> The first change alone shaved off 220ms off the runtime, the 2nd one cuts
> 130ms
> and the 3rd one cuts 60ms.
>
> Lesson learned: by very very careful about dynamic arrays.


Yeah, I've actually noticed this too on a few occasions. It would be nice
if array operations would unroll for short arrays. Particularly so for
static arrays!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130531/980559c3/attachment.html>


More information about the Digitalmars-d mailing list