sousou03 / glmatrix

Automatically exported from code.google.com/p/glmatrix
0 stars 0 forks source link

Using closures much faster than typed arrays #34

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Using javascript closures is faster than typed arrays.
See this benchmark in my clone: 
http://danielheres-glmatrix2.googlecode.com/hg/benchmark/matrix_benchmark.html?r
=a1885c17e9a5e0f319ddf6e31e59e08f7e59ac84

Original issue reported on code.google.com by danielhe...@gmail.com on 28 Dec 2010 at 1:25

GoogleCodeExporter commented 8 years ago
http://jsperf.com/improved-glmatrix-or-not

I did some test there and it seems you were quite right.
Even my complete test seems to get pulverized by it. Which is quite weird 
considering the extra function cal needed to get to a Float32Array.

Original comment by jeroom832@gmail.com on 29 Dec 2010 at 10:03

GoogleCodeExporter commented 8 years ago
Yes I found it also strange, but I stumbled upon it while trying to optimize 
something, which got two times slower when i used int32 array instead of a 
closure.
I think it is because the engines are not fully optimizing the typed arrays yet 
(especially v8 of course).
Transpose seems like a bug in Firefox tracer, in v8 it is much faster than the 
original.

Original comment by danielhe...@gmail.com on 29 Dec 2010 at 10:47

GoogleCodeExporter commented 8 years ago
If you continue with this library, wouldn't it be better to rename it. As it 
stands now, It could really confuse new users by just using the name glmatrix2. 
Because it still has a large difference now.

Original comment by jeroom832@gmail.com on 30 Dec 2010 at 8:01

GoogleCodeExporter commented 8 years ago
I don't continue it, it was to play with this idea. I hope the idea will be 
picked up.

Original comment by danielhe...@gmail.com on 30 Dec 2010 at 9:10

GoogleCodeExporter commented 8 years ago
actually It gave me an idea. It could create a matrix object and keep a speed 
similar to your library 

preview:
http://jsperf.com/testers

Original comment by jeroom832@gmail.com on 30 Dec 2010 at 1:04

GoogleCodeExporter commented 8 years ago
This is a very interesting optimization, but unfortunately it would clash with 
some of the other goals of the library (like being able to use any array as a 
matrix/vec). I'll certainly keep it in mind, since there still may be other 
ways to apply it, but I don't think I can implement it in the library as is 
without some serious backwards compatibility breaking.

Original comment by Tojiro@gmail.com on 27 Feb 2011 at 5:00