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!