Easily capturing response time metrics using the Watir-WebDriver-Performance gem

I don’t like long dedicated performance testing windows at the end of a project. I see response times as non-functional requirements, and like any other requirements, these should be tested as we’re going along. One way of effectively measuring performance testing is by conducting a response time test every time you do a build, if there’s a big degradation in performance: break the build!

A couple of months ago, Tim Koopmans released the Watir-WebDriver-Peformance gem. It’s aimed at providing a set of navigation timing metrics for Watir-WebDriver actions. This is a perfect solution to capture response time metrics, and it’s very straightforward to do (only works in Chrome and IE9 at the moment – no Firefox support).

require 'watir-webdriver'
require 'watir-webdriver-performance'

b = Watir::Browser.new :chrome

10.times do
  b.goto 'http://watir.com'
  puts "Load Time: #{b.performance.summary[:response_time]/1000} seconds."
end  

This produces something like:

Load Time: 3.701 seconds.
Load Time: 0.694 seconds.
Load Time: 1.874 seconds.
Load Time: 1.721 seconds.
Load Time: 2.096 seconds.
Load Time: 0.823 seconds.
Load Time: 2.362 seconds.
Load Time: 1.008 seconds.
Load Time: 1.761 seconds.
Load Time: 2.066 seconds. 

List of available metric groupings

  • :summary
  • :navigation
  • :memory
  • :timing

Summary

The Watir-WebDriver-Performance gem is a great way to capture response time metrics from your Watir-WebDriver automated tests. By instrumenting your existing Watir-WebDriver automated tests that run regularly as part of a continuous integration process, you can start to capture and measure web application performance over time, and be alerted to the possibility of a change being introduced with adverse performance effects. Well done Tim!

One thought on “Easily capturing response time metrics using the Watir-WebDriver-Performance gem

  1. This is a good gem and very useful for page load information. However in my case I was wondering if you had a solution to calculating response time of an action (not necessarily page load.) For example, I have a 1 page site. Everything loads dynamically. Jmeter does a fine job getting response times of the service calls, but since it’s not a full browser, I can’t really see how long it takes to run a AJAX request in IE vs. FF, vs Chrome… and so forth.

    Do you know of any solution to set timers on the actual Cucumber steps or actions themselves?

Comments are closed.