Node.js module performance

  • Tried it on 0.10.36 , 0.12 and io.js 1.4.3 to see difference between node versions. Almost identical results, except for v2, which has a huge difference... https://gist.github.com/AntouanK/ab089b3380a7ff73b8f7

  • Am I incorrect in my normal usage of "x" when conveying relative performance? With 120.8498 vs 120.4320 being conveyed as "1.00 x slower". Is this the correct terminology for results that are on par with each other? Really, these results are (relatively) unchanged. Shouldn't it be 0.003x slower, with the formula being (Old / New) - 1.

    From the page:

    Result Node.js v0.12.0

    Called v2, util.yo("man") 100.000.000.000 times in 120.849870219 sec (1.00 x slower than v3)

    Called v3, util.yo("man") 100.000.000.000 times in 120.432087601 sec

  • Calling prototype functions directly from the constructor function instead on the objects doesn't make much sense. So I'm not sure how to value the results.

  • If you want, you can run these test yourself: https://github.com/5orenso/javascript-module-performance

    I'll then present the results on a nice webpage :)

  • v2 uses shared opt object, so using another new utils(opt) will override your previous options.

  • Extremely educational, thanks.

    I started using Node for some things where PHP feels inadequate (async network requests), and overall I'm happy with the speed, but after years of PHP it's been rough figuring out the right way to do objects. I don't need nearly this many requests, but I find it useful to internalize micro-optimizations to make your code a speed demon

  • Is the call to console.log really there in the benchmarked version 3?

  • I don't get it. Why would you care about the performance of your module boilerplate?