This page benchmarks the performance of a collection of matrix libraries most of which are intended for use with WebGL:
glMatrix (v3.4.0, 2023-4-11),
mjs (rev 16, 2010-12-15),
CanvasMatrix,
EWGL_math (rev 32, 2011-03-15),
the math utilities in Google's Closure (svn rev: 1364, 2011-11-3),
tdl (commit: 59d484f, 2011-06-03),
twgl.js (v3.3.0, 2017-05-05),
wgpu-matrix (v1.0.0, 2023-04-1), and
Sylvester (v0.1.3, 2007-07-05).
Benchmarks for each library are run in an iframe. Results measure millions of iterations per second of the target operation.
Library | Multiplication | Translation | Scaling | Rotation (Arbitrary axis) | Rotation (X axis) | Transpose | Inverse | Vector Transformation | Average |
glMatrix-float64 | 21.16 | 38.51 | 46.46 | | | | | | 35.37 |
glMatrix | 21.18 | 38.49 | 46.36 | | | | | | 35.34 |
glMatrix-native | 20.83 | 38.54 | 46.48 | | | | | | 35.28 |
Adapted by Stephen Bannasch from the benchmarks Brandon Jones created in his glmatrix library.
Additional improvements by Gregg Tavares.
Sylvester benchmarks by Felix E. Klee.
JavaScript Plotting library: Flotr;
Sortable Table by Andrew Tetlaw.
The source code for these benchmarks can be found here on github. Pull requests quite welcome!
=============================================
Multiplication
=============================================
glMatrix-native - Avg: 20826666 iterations per second, Min: 18170000 iterations per second, Max: 21310000 iterations per second
glMatrix-float64 - Avg: 21157000 iterations per second, Min: 19490000 iterations per second, Max: 21386666 iterations per second
glMatrix - Avg: 21176000 iterations per second, Min: 19580000 iterations per second, Max: 21433333 iterations per second
=============================================
Translation
=============================================
glMatrix-native - Avg: 38543666 iterations per second, Min: 37026666 iterations per second, Max: 38840000 iterations per second
glMatrix-float64 - Avg: 38506666 iterations per second, Min: 36683333 iterations per second, Max: 38893333 iterations per second
glMatrix - Avg: 38493000 iterations per second, Min: 36376666 iterations per second, Max: 38856666 iterations per second
=============================================
Scaling
=============================================
glMatrix-native - Avg: 46482000 iterations per second, Min: 43513333 iterations per second, Max: 46900000 iterations per second
glMatrix-float64 - Avg: 46461333 iterations per second, Min: 43696666 iterations per second, Max: 46913333 iterations per second
glMatrix - Avg: 46355666 iterations per second, Min: 42990000 iterations per second, Max: 46843333 iterations per second