GithubHelp home page GithubHelp logo

Comments (5)

domenic avatar domenic commented on July 28, 2024

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.

wwalser avatar wwalser commented on July 28, 2024

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.

Yaffle avatar Yaffle commented on July 28, 2024

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.

Yaffle avatar Yaffle commented on July 28, 2024

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.

domenic avatar domenic commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.