Coder Social home page Coder Social logo

Comments (2)

bcherny avatar bcherny commented on September 13, 2024

The async test is calling a function that calls another function, so the return statement in it is at least 2 function calls deep. The sync test, on the other hand, doesn't call any functions.

A quick jsperf test case reveals that each nested function call roughly halves performance. So with basic naive function calls in IIFC's (to simulate a root function call in benchmark.js), we would expect a 4x reduction in performance, not the 300x reduction we're seeing.

Possible explanation: V8 optimizes those jsperf test cases because they are so simple, and for more complex functions (like deferred.resolve) the drop in performance is actually an order of magnitude greater than 50%. Looking through the bjs code there is no obvious difference between how a/sync code is run - it seems to be executed the same way after the compilation step. Hopefully @jdalton or @mathiasbynens can chime in to clarify.

from benchmark.js.

jdalton avatar jdalton commented on September 13, 2024

This is a dup of #39, see it for details.

from benchmark.js.

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.