By this I mean I wanted to determine how much network and server time was spent processing a request initiated by a Watir script. Server time as defined by time to first buffer and network time as time to last buffer (minus the first).
I couldn’t really do this from Ruby itself, so I installed Fiddler. Fiddler lets you capture traffic in much the same way as ethereal / wireshark but with a nice GUI. There are some Fiddler customization scripts which let you display this info in the Custom column i.e.
oSession["ui-customcolumn"] = "FB: " + oSession["X-TTFB"] + "; LB: " + oSession["X-TTLB"];
But if you’re a neat freak like me and want them in separate columns then do this:
public static BindUIColumn("Time")
function CalcMethodCol1(oS: Session){
if (null != oS.oRequest) return DateTime.Now.ToString("dd/MM/yy HH:mm:ss.ffff");
else return String.Empty;
}
public static BindUIColumn("AbbreviatedUrl")
function CalcMethodCol2(oS: Session){
if (null != oS.oRequest) return oS.url.substring(oS.url.lastIndexOf("/"));
else return String.Empty;
}
public static BindUIColumn("TTFBuffer")
function CalcMethodCol3(oS: Session){
if (null != oS.oResponse) return oS["X-TTFB"];
else return String.Empty;
}
public static BindUIColumn("TTLBuffer")
function CalcMethodCol4(oS: Session){
if (null != oS.oResponse) return oS["X-TTLB"];
else return String.Empty;
}
You place them before you declare the static function OnBeforeRequest. The time stamp used above ends up being the ‘end’ timestamp, not the ‘start’ so you just need to subtract time to last buffer to determine that. You end up with this in your summary view:

Once this is done you can pretty up the results by copying the ‘Full Summary’ for your selected sessions in Fiddler and pasting them into Excel. This was the main reason for doing this. If you’re happy with the Fiddler ‘timeline’ view then you don’t need to bother. I just wanted the data so I could merge/correlate with other data sources.

Would be interested to know if anyone has achieved this in ruby itself. I was thinking of using the webrick/httpproxy but would have come short if testing a HTTPS web app.
Read More