On 31 May 2013 15:49, finalpatch <fengli@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!