JavaScript Performance Testing – An Indispensable Tool

Over the course of the last couple of weeks I have been looking into various tools to test Javascript Pefromance. I needed a way to test various JavaScript code snippets to see the overall latency/run time of each. I started looking for a way to manage the tests and be able to reference them in an easy way. Here are a couple of the performance suites I looked at and afterwards, my decision.

JSLitmus

You can find the source for JSLitmus here. It has a great set of features and allows you to install it on your own site. So here are some pros and cons I found when setting up JSLitmus.

Pros:

  • Single-file install (JSLitmus.js)
  • Works on Firefox, Opera, Safari, IE, Google Chrome, and iPhone browsers
  • Adaptive test cycles – tests take ~1-2 seconds, regardless of the operation
  • Google Chart + TinyUrl integration
  • Open Source MIT-style license (see source)

source: <http://www.broofa.com/Tools/JSLitmus/>

Cons:

  • Need to host this on your own server.
  • Need a place to save off/Manage existing Tests.
  • Some tests report “Infinity” when run, which meant that the tests were executing so fast that it couldn’t get an accurate read on the total OPS/Sec.

Conclusion:

JSLitmus is a nice set of tools. If you have access to your own host and are able to put together a way to manage the tests, I would recommend this is a possible solution. However, I did not go with this solution.

JSPerf

I found JSPerf.com after digging through the posts that Paul Irish’s put together about jQuery. 10 Things I Learned from the jQuery Source and 11 More Things I Learned from the jQuery Source. If you haven’t had a chance to read those, I highly recommend them, they help to give you a bit more information on whats going on in jQuery. They are also what lead me down the path to figure out why certain queries are slower than others, but thats another post all together.

Pros:

  • JSPerf is based on benchmark.js a very powerful performance testing suite.
  • Has an online environment to store and test JS
  • You can download the source and run it on your own host.
  • You can browse through other peoples tests, make changes and save copies.
  • You can see most popular tests
  • Has quick links to embed common JS frameworks
  • Uses a java jar to refine time calculations rather than just relying on JavaScripts built in time.

Cons:

  • Browsing tests is a pain in the online tool
  • Saving a copy of a test just adds a revision number to the end of the url rather than allowing you to create a new url for the test.
  • Sometimes test runs aren’t saved off properly. I noticed this on my Mac using Safari 5.0.3

Conclusion:

JSPerf seems to be able to handle all the aspects I need for everyday performance needs. I will be setting up a copy on this host, just so I can keep my own tests around and not need to bookmark them for reference later on.

Conclusion

Overall, I think JSPerf is the hands down winner at this point. Doesn’t mean I won’t find a better solution down the road, but for now, being able to quickly write a test on jsPerf and just run it to see how well it performs is much easier than hosting my own performance suite.

In the next couple of days I will be posting some of my performance test runs and some of the conclusions based on those results.

3 thoughts on “JavaScript Performance Testing – An Indispensable Tool”

  1. I just stumbled across your site. Pretty interesting topic, it really makes one think. I am going to have to look at some of your other posts.

Leave a Reply to King Katie Cancel reply

Your email address will not be published. Required fields are marked *