Benchmarking with HTTPerf.js and NodeUnit
Posted in: Performance Testing   -   August 7, 2013

I covered this in the HTTPerf.js docs a bit, but wanted to take a deeper look at how I use HTTPerf.js and NodeUnit to benchmark web applications.
Note on benchmarking. I’ve gone back and forth on using median and 85th percentile when benchmarking. I look at 85th percentile when running load tests and performance tests — basically when I’m trying to break my site. However, for simple benchmarks like this, median gives you a better perspective.
In my docs, I have this basic example. It’s pretty simple for small sites, where you want to benchmark just a few endpoints.

Setup

Before getting started you’ll need to install node, httperf, HTTPerf.js and NodeUnit.

Benchmark Example One

file: benchmark.jsRun with:

Benchmark Example Two

Now, let’s pretend we have a real site, with a lot of endpoints that we potentially want to benchmark the performance of. The above will work, but as your list grows it will gradually become harder to maintain. In this example, I build my list of urls using an external json file and use a factory function within my test to generate the complete test cases. file: tests.jsonfile: benchmark.jsRun with:This should generate some simple and pretty output like so:Enjoy!

This was originally posted with the same title on mervine.net on 07/17/13.


Joshua Mervine (@mervinej) has spent the last 15 years working in Development and Operations, both as an individual contributor and manager. He currently leads the Dev Ops team for http://www.yellowpages.com. Joshua is passionate about open source and maintains a blog (mervine.net) where he shares his experiences and projects.

Tags: , , , , ,

  • Chris Ueland

    nice post, Josh!

    • http://www.rubyops.net/ Joshua Mervine

      Thanks Chris!

  • http://www.rubyops.net/ Joshua Mervine

    I’ve made some updates to this post here: http://mervine.net/benchmarking-with-httperfjs-and-nodeunit, including setup instructions. I’ll update this post as soon as I can.

    • http://blog.justindorfman.com jdorfman

      Great job dude!

  • iced artbrain

    when i follow your manual
    it going error
    [root@localhost .bin]# ./nodeunit /home/netflow/benchmark.js

    /home/netflow/node_modules/nodeunit/lib/nodeunit.js:72
    if (err) throw err;
    ^
    Error: ENOENT, stat ‘/home/netflow/node_modules/.bin/home/netflow/benchmark.js

    why it happen, please reply for information