[Public WebGL] JavaScript matrix libraries really 5x faster in Minefield than Chrome?

On Lee [email protected]
Mon Feb 14 09:53:18 PST 2011

One more thing to consider is the quality of the code. 


I used to use the J3DIMath.js used in
http://www.khronos.org/webgl/wiki/Tutorial.  We found at least a bug after
spending hours on it. Please see
2> &t=3231&p=9862#p9862 discussion. I switched to mjs
<http://code.google.com/p/webgl-mjs/> .


http://learningwebgl.com/cookbook/index.php/Main_Page#Matrix_libraries shows
various matrix libraries.


I'd be great if there is a recommended high-quality and
actively/well-maintained matrix library.



-- On Lee


From: [email protected] [mailto:[email protected]]
On Behalf Of Gregg Tavares (wrk)
Sent: Monday, February 14, 2011 9:16 AM
To: public webgl
Subject: Re: [Public WebGL] JavaScript matrix libraries really 5x faster in
Minefield than Chrome?


So I probably shouldn't respond to this because being on the Chrome team no
matter what I say it will sound defensive but:


*) Are you sure these are valid tests? Rumor is some JavaScript engines will
see that the results you are calculating are never used and optimize the
entire test away. I don't know if Minefield goes that far though if it did
that would be pretty cool


*) Are you sure they are computing the same things? For example mjs doesn't
appear to have a true matrix inverse so you're comparing apples to oranges
vs the other  libraries there.


*) I added the math library from the tdl stuff. They are slightly faster at
some things and slower at others. Attached (sorry, new to git)


*) Matrix math isn't everything. For example running the webgl aquarium on
FF4b11 vs Chromium 11.0.668.0 (74525) on your hardware (I have the same
machine) using this url



At 50 fish


FF: 40fps

Chromium: 60fps


At 1000 fish


FF: 25fps

Chromium: 60fps


I bring that up because it's hard to compare matrix math libraries as they
don't all do the same thing. For example, many of the matrix math libraries
create objects like a Matrix4 object. Others don't and just use JavaScript
arrays or Float32Array completely un-augmented. Which is better? No idea. If
it turns out objects are slower but more convenient which would you pick?
Another example, some libraries work better if you give them a destination
variable. I think mjs this is true and I know the tdl fast library (which
sadly is not so fast) also requires that. But your benchmark doesn't take
those differences into account. Another is that you're almost always doing
your math in place meaning you pass in a matrix and expect that matrix to be
translated, rotated or scaled in place rather than returning a new matrix
and leaving the original alone. That difference is not taken into account.

Of course none of that explains why FF is 5 times faster for your test as it



On Sun, Feb 13, 2011 at 8:55 PM, Stephen Bannasch
<[email protected]> wrote:

Are JavaScript matrix libraries suitable for WebGL programming really 5x
faster in Minefield than Chrome ... and about twice asfast in Chrome than in
a WebKit nightly?


This is what I found with an adaptation of with Brandon Jones's benchmarks
in his glmatrix library: https://glmatrix.googlecode.com/hg/


See the data below ...


I was working with the JavaScript graphing library flotr and wanting to pick
a matrix library for some webgl work so I adapted the benchmarks Brandon
Jones created in his glmatrix library: https://glmatrix.googlecode.com/hg/.


My changes include:

- I'm only including the benchmarks.

- I've updated to the latest mjs as of Dec 15: 16:8e5b0944ef1e and included
it in several more tests.

- I've also added a graph display of the results using flotr, see:


My fork of these benchmarks are available here:


And you can run them in a browser with webgl at this url:


[The somewhat lame reason this is a fork is that it was taking me longer
thanI wanted using mercurial (don't use hg much) to follow the typical
workflow I use on github, fork a repo, push my changes into a branch and
send a pull request to the original developer ...]


The following data were generated on a MacBook Pro running MacOS X 10.6.6
with a 2.66 GHz Intel Core i7 and a NVIDIA GeForce GT330M 512MB


Google Chrome 9.0.597.102




WebKit nightly 78038



Minefield 4.0b12pre (2011-02-13)









-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110214/428390eb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 67308 bytes
Desc: not available
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110214/428390eb/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 75569 bytes
Desc: not available
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110214/428390eb/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 54971 bytes
Desc: not available
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110214/428390eb/attachment-0002.png>

More information about the public_webgl mailing list