使用fiddler以毫秒为单位获取会话时间



因此,fiddler烹饪书列出了一种通过添加上下文菜单获取每个会话计时信息的方法。这是性能测试下的最后一个示例代码块。

public static ContextAction("CopyTimers")
function CopyTimers(oSessions: Fiddler.Session[]){
if (null == oSessions){
  MessageBox.Show("Please select sessions to copy timers for.", "Nothing to Do");
  return;
}
var s: System.Text.StringBuilder = new System.Text.StringBuilder();
for (var x = 0; x < oSessions.Length; x++)  {
  s.AppendFormat("{0}, {1}, {2}, {3}, {4}, {5}, {6}rn",
  oSessions[x].Timers.ClientConnected,
  oSessions[x].Timers.ClientDoneRequest,
  //oSessions[x].Timers.ServerConnected,
  oSessions[x].Timers.ServerGotRequest,
  oSessions[x].Timers.ServerBeginResponse,
  oSessions[x].Timers.ServerDoneResponse,
  oSessions[x].Timers.ClientBeginResponse,
  oSessions[x].Timers.ClientDoneResponse
);
}
Utilities.CopyToClipboard(s.ToString());
MessageBox.Show("Done.");
}

注意,我不得不注释掉其中一行,因为脚本似乎无法编译。(因此必须将参数数量更改为AppendFormat)

不幸的是,这只能给出精确到秒的时间。如何得到毫秒级的时间?我在哪里可以找到关于Fiddler脚本可用对象的一般信息?

技巧是在Fiddler可执行文件上使用Visual Studio之类的对象浏览器来探索Fiddler中可用的内容。

Session类有一个计时器变量,它确实返回一个System.DateTimes数组。

我们可以使用格式化字符串来获取毫秒数,如ToString("hh:mm:ss.ffff")。

最新更新