Tracking service call durations and times on Fiddler

Here's some scripts for custom columns that I use on a daily basis. Helps me a lot to keep track of when webservice calls were made and how long they took:

This method gives you a column with the duration of a web call, formatted into a time:
       public static BindUIColumn("Duration")
       function CalcDurationCol(oS: Session)   
       {
              var sResult = String.Empty;
              if ((oS.Timers.ServerDoneResponse > oS.Timers.ClientDoneRequest))
              {
                     sResult = String.Format("{0:H:mm:ssss.ffff}", (oS.Timers.ServerDoneResponse - oS.Timers.ClientDoneRequest));
              }
              return sResult;
       }


This method gives you a column with the time that the request was started:

       public static BindUIColumn("RequestTime")
       function CalcRequestTimeCol(oS: Session){
              if (null != oS.oRequest)
                     return String.Format("{0:H:mm:ssss.ffff}", oS.Timers.ClientBeginRequest);
              else
                     return String.Empty;
       }

   
This method gives you a column with the time that the request ended:
             
       public static BindUIColumn("CompletedTime")
       function CalcCompletedTimeCol(oS: Session){
              if (null != oS.oRequest)
                     return DateTime.Now.ToString("H:mm:ss.ffff");
              else
                     return String.Empty;
       }


 (Don't mess with these time formats, they work as is and don't want to be changed J .It will cause an exception in Fiddler if the formats are incorrect. So be careful if you are going to change them)

You can past these methods in anywhere into FiddlerScript. I added mine in after the OnBeforeResponse method, as this normally has some other code for custom columns as well. To keep it all close to each other.

The reason that I do not use the predefined "customColumn" is that all that information just gets appended and displayed in the same column.

Some sample code of this:
 if (m_ShowTTLB){
    oSession["ui-customcolumn"] = oSession.oResponse.iTTLB + "ms " + oSession["ui-customcolumn"];
}


(I currently have this in my custom column, showing me the duration in milliseconds. Which is also very useful.) 

Hope this helps someone :) 

Comments