Comments (5)
Good call; I think the reason it looks as it does is only a historical accident. Feel free to submit a pull request :)
from setimmediate.
I'll be flying for the next three days so I can't look into the performance of this in particular and actually Dom sent me something earlier this week that I haven't been able to look into yet either. You may be correct that this is what's causing the problem that I saw a few weeks ago in my own performance tests.
In brief my findings were that messageChannel would be faster than setTimeout 0 for the first three to five thousand iterations but then suddenly slow down to become the same speed. I suppose that problem could be a GC issue in which case your change would fix it. It could also be a generic MessageChannel performance problem.
https://gist.github.com/2718412
That page shows the basics of my performance tests, I've thought of some other approaches that I'd like to try out in a few days.
from setimmediate.
Chrome 21
with MessageChannel (before fix)
timeout: 1223
immediate: 4054
delta: 2831
percentage: 30.167735569807597
with MessageChannel (after fix)
timeout: 1221
immediate: 51915
delta: 50694
percentage: 2.351921409997111
with postMessage:
timeout: 1223
immediate: 60765
delta: 59542
percentage: 2.0126717682876656
with postMessage (with 3 additional listeners for "message" event):
window.addEventListener('message', function (event) {
if (event.data === 'test') {
console.log('test');
}
}, false);
timeout: 1222
immediate: 52358
delta: 51136
percentage: 2.333931777378815
from setimmediate.
seems,
delay with postMessage depends
on number of listeners for "message" event
window.addEventListener('message', ...)
so.... MessageChannel can be more preferable
(this is not fixed in my pull request)
from setimmediate.
Right, it's a good point. Hard to say which is best. Will have to think on it further, maybe gather more cross-browser data.
from setimmediate.
Related Issues (20)
- new Function('return this')() is eval == bad code HOT 8
- How about requestIdleCallback? HOT 2
- global.postMessage issue HOT 2
- Redefining `global.onmessage` is breaking Firefox 49 HOT 3
- documentation missing from the package HOT 1
- Not relying on global scope HOT 1
- How about Promise? HOT 1
- window vs self HOT 7
- setImmediate blocks setInterval in webworker (Chrome) HOT 1
- postMessage is 'undefined' and throws 'setImmediate is not defined' error HOT 7
- error: this is not a function
- setTimeOut HOT 1
- Cannot read property 'bind' of undefined HOT 2
- Long wait in IE9 - IE11
- Thank you and the future
- How relates to `queueMicrotask` HOT 1
- Deno support
- Deno support
- Referencing `setImmediate` prevents a Deno process from finishing
- postMessage triggering webworker communication HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from setimmediate.