Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

API Wrapper for webpagetest.org

branch: master
README.md

Susuwatari

Susuwatari (ススワタリ lit. meaning "travelling soot") is the name of the dust bunnies featured in Studio Ghibli Animes My Neighbour Totoro and Spirited Away.

An Introduction for the Impatient (tl;dr)

This gem allows you to use the API of Patrick Meenan excellent webpagetest.org and fetch scores, numbers and waterfall images.

require 'susuwatari'

mei = Susuwatari.new( url: 'google.com', k: '5566sdfdsf' )
mei.run
=> "aASFDasfdads2"

mei.status
=> :running

mei.status
=> :completed

mei.result.keys
 => [ "test_id", "summary", "test_url", "location", "connectivity",
      "bw_down", "bw_up", "latency", "plr", "completed", "runs", "average",
      "median", "run"]

mei.result.test_id
=> "aASFDasfdads2"

mei.result.run.first_view.images.waterfall
=> "http://www.webpagetest.org/results/12/02/09/KG/35XV333/1_waterfall.png"

mei.result.run.first_view.results.score_cache
=> "98"

mei.result.run.first_view.results.requests
=> 12

You can check what a result looks like here.

So why Susuwatari?

Premature optimization might be the root of all evil, but optimizing actual performance bottlenecks is uniquely satisfying.

Optimizing a web page from the end user perspective is even more satisfying, so we figured we need a way to monitor the web page speed on a regular basis.

This gem allows to you test your url using webpagetest.org and get all the relevant numbers (imho) in a structured form. Looking at the waterfall charts allows you to squash all those little nasty dust bunnies that will slow down your page.

Squashing Susuwatari

So how to use it?

You need an api key from webpagetest.org to use this gem. You can find more information about that on the Developer Interfaces Documentation.

Once you've installed the gem, you can use it like this:

require 'susuwatari'

mei = Susuwatari.new( url: 'google.com', k: 'your-key', from: 'detroit', using: 'Chrome')

mei.run
=> 'aBd333'


# You can check the status.
mei.status
=> :running

mei.status
=> :completed

mei.result.keys
 => [ "test_id", "summary", "test_url", "location", "connectivity",
      "bw_down", "bw_up", "latency", "plr", "completed", "runs", "average",
      "median", "run"]

#You can access the results as a hash
mei.result[:test_id]
=> 'aBd333'

#Or in a pseudo-object oriented fashion
mei.result.test_id
=> 'aBd333'

Locations

To see a list of all the available locations and how you need to pass the location parameter check locations

Something went wrong with that request. Please try again.