Closed idiotWu closed 3 years ago
Yeah, I found that Math.js wraps normal JS arrays. Hence why it's slow. It also doesn't do a lot of optimizations. It seems to be more focused on correctness and extensibility than speed sadly.
Instead of reimplementing all these ourselves, I would like to see if there is a well-supported LinAlg library we can leverage. At the very least, we are using arrays of arrays in JS which are really slow, so anything that doesn't use those should perform faster.
@idiotWu It may be overkill but how does the benchmarking for Eigen.JS look? https://github.com/BertrandBev/eigen-js
Here is there official benchmarking: https://bertrandbev.github.io/eigen-js/#/benchmark
@Skylion007
At the very least, we are using arrays of arrays in JS which are really slow, so anything that doesn't use those should perform faster.
Well, JS native arrays are actually fast on modern browsers. I thought TypedArray based implement would be faster, but in my tests ml-matrix (the only TypedArray
based linalg lib I've found so far) does not seem to be much faster than math.js. What's more, a total refactoring is necessary if we want to use TypedArray
.
Eigen.js seems to be as slow as math.js
:
@idiotWu
I just dropped in to say a big THANK YOU! You've solved the issue which held me back from making my chrome extension. I am super grateful, and going to mention your code as well when the extension will be out.
Istvan
@idiotWu Thanks. I needed to use webgaizer in google extension with manifest v3 but with new model with landmarks. I used @idiotWu's idea for the latest revision of the webgaizer. https://github.com/koll93/WebGazer/tree/refactor-remove-numeric-landmarks
Resolves #211.
This PR replaced numeric with mathjs to fix the CSP error as mentioned in #211. I'm not able to run the test script because files under
www/data/src/P_01/
are missing, but the demo pages seem to be working.As a side effect, the bundle size increased from 2.1M to 3.2M (both minified).