How to comparing the performance of different JavaScript snippets by running benchmarks?

JavaScript

Perform JavaScript benchmarks by “hand” sometimes consume a lot of time, can be tedious and can be considered a hard task, well, hopefully I recently discover a nice tool called jsPerf to perform that JavaScript benchmarks tasks.

jsPerf is:

“jsPerf aims to provide an easy way to create and share test cases, comparing the performance of different JavaScript snippets by running benchmarks. But even if you don’t add tests yourself, you can still use it as a JavaScript performance knowledge base.”

jsPerf is powered by Benchmark.js a JavaScript benchmarking library that works on nearly all JavaScript platforms, supports high-resolution timers, and returns statistically significant results. Kudos to John-David Dalton for his awesome work on this project!

If you are looking for a specific topic the site already have a list of test case, I have used the thread DOM vs innerHTML based Templating and created two versions to test some JavaScript Template Engines, so go ahead and start creating your own test cases!!

My versions