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

Stephen Bannasch [email protected]
Mon Feb 14 10:31:59 PST 2011


At 9:15 AM -0800 2/14/11, Gregg Tavares (wrk) wrote:
>So I probably shouldn't respond to this because being on the Chrome team no matter what I say it will sound defensive but:

Greg,

I'm very glad you did respond ...  I'm pretty new to this and I shared this just to open this kind of discussion.

>*) Are you sure these are valid tests?

I don't know much about benchmarking the matrix operations. This code is based on Brandopn's work.

The input matrices to the tests are created with random values so that presumably makes optimization less of an issue.

https://github.com/stepheneb/webgl-matrix-benchmarks/blob/master/matrix_benchmark.html#L85

>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)

Thanks, I've pushed your tdl library addition to the git repo so they're now included also.

   http://stepheneb.github.com/webgl-matrix-benchmarks/matrix_benchmark.html

The graph now updates in real-time also.

>*) 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
><http://webglsamples.googlecode.com/hg/aquarium/aquarium.html?webgl=%7Bantialias:false%7D>http://webglsamples.googlecode.com/hg/aquarium/aquarium.html?webgl={antialias:false}
>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 tobe translated, rotated or scaled in place rather than returning a new matrix and leaving the original alone. That 
>difference is not taken into account.


Yes, definitely true.

I did this work because I wanted to pick a matrix library to use (and I needed to learn more about flotr for a related project).

I was surprised that the only library that seems to have a relatively large number of unit tests is Sylvester.

- tdl is fast and has nice documentation in the code but no tests
- glmatrix is fast and has four tests
- mjs is fast, has html documentation in the repo.
- ewgl is slower and doesn't seem to have much doc in the repo

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

Yes ... I find that a mystery also.

I am curious if other people using different computers also see a similar speedup in Minefield and a similar slowdown in 
WebKitnightly?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110214/2bf0e706/attachment.html>


More information about the public_webgl mailing list