<div dir="ltr">On 31 May 2013 15:49, finalpatch <span dir="ltr"><<a href="mailto:fengli@gmail.com" target="_blank">fengli@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks Nazriel,<br>
<br>
It is very cool you are able to narrow the gap to within 1.5x of c++ with a few simple changes.<br>
<br>
I checked your version, there are 3 changes (correct me if i missed any):<br>
<br>
* Change the (float) constructor from v= [x,x,x] to v[0] = x; v[1] = x; v[2] = x;<br>
* Get rid of the (float[]) constructor and use 3 floats instead<br>
* Change class methods to final<br>
<br>
The first change alone shaved off 220ms off the runtime, the 2nd one cuts 130ms<br>
and the 3rd one cuts 60ms.<br>
<br>
Lesson learned: by very very careful about dynamic arrays.</blockquote><div><br></div><div style>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!</div>
</div></div></div>