4 ms·
I usually just do something like this: var loop = function() { for (var i=0; i<1000; i++) { // do stuff } setTimeout(loop, 0);
by Retr0spectrum 11y ago
I usually just do something like this:
var loop = function() {
for (var i=0; i<1000; i++) {
// do stuff
}
setTimeout(loop, 0);
}
It might not be as fast in some cases, but it works for me.
- yangmillstheory 11y agoIt works - and that's the core of what's being done if you look at the code. I just wanted to make something re-usable, configurable, and play around with ES6 generators :).
- Retr0spectrum 11y agoDo you think it would be possible to dynamically adjust the chunk size for optimum performance on different hardware/browsers? That would be very useful.
- yangmillstheory 11y agoThe API exposes the chunk/delay parameters as options, so it's definitely possible. If you mean having the library code "learn" the optimal chunk/delay for a given run, that's possible too, but I'd have to wonder about alternative solutions at that point.
- yangmillstheory 11y agoI you look at the demo site again, I made the chunk size and delay user-configurable, and I'm displaying the current running code.