-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of max
and min
#212
Comments
but |
Check out this: http://jsbin.com/vativ/1/edit?js,console. FWIW, running that on my phone (what I'm on right now) is actually ~200x faster. I've tried quite a few ways of doing this and using Math.max is easily the fastest. The code to do it in math.js wouldn't be near as elegant as the current version you have (nice use of closures) but it's not too bad. I'm thinking of coding it up myself so look for a pull request. BTW, this looks like a great library. High quality code, good documentation. That's why I'm actually interested in contributing. Paul From: Viktormailto:[email protected] but Reply to this email directly or view it on GitHub: |
math.js is slower because it's doing type-checking of all array values. Performance improvements for matrix operations in general is on the radar, see for example #275. Is it ok with you to close this issue? |
Using
Math.max.apply(null, array)
is ~100x faster on large arrays than the currentmax
andmin
implementation.Note that Chrome has a limit of ~100k arguments when using
.apply
so arrays larger than 100k values need to be done in batches. See here.The text was updated successfully, but these errors were encountered: