4 ms·
Hmm, I think the performance results for the last example aren't actually valid. The example/tco.js program is a linear-time algorithm since it's only making on
by alangpierce 8y ago
Hmm, I think the performance results for the last example aren't actually valid. The example/tco.js program is a linear-time algorithm since it's only making one recursive call, not two, so at n=50 you should expect it to be pretty much instant. Much, much less than a millisecond to evaluate.
I think the "0.080 total" and "0.087 total" are just from node startup time (and the variability within that), not time actually executing the function. I just ran node on an empty file and the running time was "0.087 total".
I think when doing these sorts of perf measurements it's best to make the code run for multiple seconds to better account for startup time, JIT warmup, caches, and the various other subtle factors that come into play.
- snek 8y agoI cannot agree more here. I strongly recommend benchmark.js (https://github.com/bestiejs/benchmark.js/ https://github.com/bestiejs/benchmark.js/)
- eatonphil 8y agoTotally fair, and thank you for the link! To focus too heavily on performance right now would be a mistake. Even longer-term, jsc's most likely application is in simplifying deployments and packaging of Node applications. I included the programs in this article because I wanted to show _some_ example of where jsc stood a few weeks in.