Search code examples
javascriptnode.jsv8

Best ways to assess minor changes in Javascript Performance


After having lots of discussions and back-and-forths about whether or not a change will help/hinder performance, I'm looking for one of the following:

  1. A comprehensive analysis of the performance of various operations broken down by environment and other factors. Something that can tell me things like:
    • Performance difference between a closure vs. a bind
    • The cost of creating an anonymous object for passing parameters vs. passing parameters directly
    • The overhead of making things asynchronous (Promise vs. direct call vs. setTimeout vs. async)
  2. The above, but not necessarily for all environments / situations. Mostly looking for nodejs / v8
  3. A good way to assess these things on my own (is jsperf still a thing?)

Can anyone help me out here?


Solution

  • How to assess minor changes in Javascript Performance?

    Write benchmarks for your application and run them from your build process. Keep the results in a database and visualise them so that you can monitor them. This is known as performance management.

    Of course, most of the things you asked about are micro-optimisations. Avoid those and focus on writing simple (maintainable) and correct code instead. If you feel you need to optimise performance, try something and measure its effects.