-
Notifications
You must be signed in to change notification settings - Fork 36
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
Is there a reason for not using slice(0)? #221
Comments
Hi @nikoskalogridis. One of the reasons that |
I see, at least in modern vms though there is a clear advantage on using native functions instead of loops https://jsperf.com/array-for-loops-vs-slice/1 |
Thanks @nikoskalogridis. A jsperf test suite for prelude would be really great! That would help us make decisions about when to deprecate bits of prelude and just use builtins. I was a little worried that some VMs would discard the calls in that JS Perf, since it'd be easy for an optimizer to prove that the result of That's an astonishing margin of victory! One technique that's typically used to ensure that perf tests are valid is to use the result in some way. For example, by adding the resulting array's Once again, astonishing! In fact, Safari, Chrome, and FF all gave the same results after consuming the resulting Thanks again for the offer to put together a complete test. We'd very much appreciate it! |
Just to be totally clear: I'm absolutely in favor of perf testing prelude and changing/deprecating/dropping functions that no longer provide benefit. I just want to make sure we are basing those decisions on valid data. Perf testing on optimizing VMs is hard since optimization is largely opaque (v8 provides some visibility, but I afaik, other VMs don't 🙁 ). |
Interesting finds, @nikoskalogridis out of curiosity did you run into some issues with the current implementation of copy and it was resolved by changing to slice(0) ? |
Browser support may also be considered. That is, how is the performance on somewhat older browsers? |
@davidchase not at all. I was just browsing through the code and I was impressed that it used for loops for manipulating arrays. I have recently also noticed myself that there is a huge performance difference on using slice(x) over other methods . So that is why I asked. My opinion regarding custom for loops, implementing native calls, is to avoid them. Browsers get updated and native calls improve all the time in each iteration. Now if there are perf issues in older browsers I think its fair to penalize the older browser instead of the new ones. But that is only my opinion ;-) |
I am just bumping this. |
core/packages/prelude/src/array.js
Line 67 in 82b380d
ie
The text was updated successfully, but these errors were encountered: