lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


as hinted in their discussion, it is purely the

pixels[index] = color
write operation that kills performance

I simply replaced the this.pixels with a ffi.double array and changed
the iterators/write ops to be based on pointers, and BAM! 30 000 rays
per second (50% faster than chrome (20 000 rps)) although I havent had
the exact machine he used for testing the browsers I think (q6600 for
me)

so the changes are quite simple in the screen.lua

--this.pixels = {}
this.pixels = ffi.new("double[?]", this.width * this.height * 3)

and during writing/reading use pointer ops

--this.pixels[index] = color
--index = index + 1

p = this.pixels
...
for i = 0, 2 do
  p[i] = color[i+1]
end
p = p + 3


2011/2/13 Alexander Gladysh <agladysh@gmail.com>:
> Hi, Mike,
>
> You may be interested in the post below, covering 4D ray-tracing
> implementations benchmarking, where LJ2 loses the battle against
> Google Chrome.
>
> I'm not making any conclusions from that — I did not look on the code,
> so please don't get angry. :-)
>
> In Russian:
>
> http://habrahabr.ru/blogs/algorithm/113250/
>
> Translation:
>
> http://translate.google.com/translate?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=en&u=http%3A%2F%2Fhabrahabr.ru%2Fblogs%2Falgorithm%2F113250%2F&act=url
>
> Alexander.
>
>