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 |
twgl-math-native | 25.14 | 93.43 | 110.49 | | | | | | 76.35 |
twgl-float64 | 29.91 | 76.80 | 93.77 | | | | | | 66.83 |
twgl-math | 24.06 | 78.27 | 94.72 | | | | | | 65.68 |
twgl-native | 25.04 | 64.61 | 99.80 | | | | | | 63.15 |
twgl | 24.02 | 62.46 | 78.85 | | | | | | 55.11 |
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
=============================================
twgl-native - Avg: 25039666 iterations per second, Min: 22630000 iterations per second, Max: 25460000 iterations per second
twgl-math-native - Avg: 25136666 iterations per second, Min: 23763333 iterations per second, Max: 25413333 iterations per second
twgl-math - Avg: 24061666 iterations per second, Min: 21890000 iterations per second, Max: 24473333 iterations per second
twgl-float64 - Avg: 29912000 iterations per second, Min: 27750000 iterations per second, Max: 30286666 iterations per second
twgl - Avg: 24019666 iterations per second, Min: 21826666 iterations per second, Max: 24486666 iterations per second
=============================================
Translation
=============================================
twgl-native - Avg: 64609666 iterations per second, Min: 59883333 iterations per second, Max: 65430000 iterations per second
twgl-math-native - Avg: 93428333 iterations per second, Min: 84456666 iterations per second, Max: 94800000 iterations per second
twgl-math - Avg: 78268666 iterations per second, Min: 71090000 iterations per second, Max: 79286666 iterations per second
twgl-float64 - Avg: 76802333 iterations per second, Min: 67566666 iterations per second, Max: 78233333 iterations per second
twgl - Avg: 62464333 iterations per second, Min: 57790000 iterations per second, Max: 63146666 iterations per second
=============================================
Scaling
=============================================
twgl-native - Avg: 99795666 iterations per second, Min: 93090000 iterations per second, Max: 101056666 iterations per second
twgl-math-native - Avg: 110492333 iterations per second, Min: 103070000 iterations per second, Max: 112800000 iterations per second
twgl-math - Avg: 94716666 iterations per second, Min: 86966666 iterations per second, Max: 95830000 iterations per second
twgl-float64 - Avg: 93774666 iterations per second, Min: 87593333 iterations per second, Max: 95403333 iterations per second
twgl - Avg: 78853666 iterations per second, Min: 73080000 iterations per second, Max: 79913333 iterations per second