Thursday, December 1, 2011

Math Libraries

Looking for fast math libraries in js turned out to be a little harder than I thought.  If we are always trying to utilize the best available tools for the job than this is something to look at.

Looking down the list of popular choices:
closure (google)
TDLFast
EWGL
glMatrix
mjs
CanvasMatrix
TDLMath

There's a benchmark for webgl matrix libraries over at: http://stepheneb.github.com/webgl-matrix-benchmarks/matrix_benchmark.html

And that's where I derived that short list from.

Running the benchmark (higher is better):

Google Chrome 17.0.x


closure (google): 24.32
TDLFast: 23.53
EWGL: 17.23
glMatrix: 16.11
mjs: 14.76
CanvasMatrix: 11.57
TDLMath: 9.04

Firefox 10.0

TDLFast: 10.39
TDLMath: 9.24
mjs: 9.00
closure: 8.97
glMatrix: 6.90
EWGL: 6.07
CanvasMatrix: 4.88

Your results will vary.  It's nice to think you have a large choice, but most of these operate in the same fashion, you're not comparing apples and oranges, you're just comparing apples that are growing on the same tree if not the same branch.  Moreover, the less code we write the better to achieve our goals, so whatever scene graph manager we choose: if it implements a particular math lib that might not be the fastest, so be it, we're not about to reinvent the wheel.


No comments:

Post a Comment