6

Glimpse's HUD provides a very useful view of the timings -- and they seem to tie into the various browser's developer tooling for network capture.

If I take a simple implementation of a custom HttpModule as detailed here by Phil Haack, I get completely different server processing timing. The timings received are always far lower than that of which Glimpse reports. Glimpse however ties far closer into the browser tooling timings.

Glimpse is obviously using a far more sophisticated technique for calculating this.

  • How does Glimpse calculate the duration for server processing times?
  • How is the wire time accurately calculated?
  • I imagine that the client timings are all based on listening to Javascript events. Is this correct?
4

1 回答 1

9

如果您查看glimpse.hud.js文件,它是发送到客户端的glimpse.js客户端文件的一部分,那么您会看到所有计时都基于由浏览器。

HUD 中 Glimpse 显示的时间是根据该 API 提供的时间计算得出的。所以首先 Glimpse 掌握了这些时间

var timingsRaw = (window.performance 
               || window.mozPerformance 
               || window.msPerformance 
               || window.webkitPerformance 
               || {}).timing; 

之后它开始计算时间,这些时间可以提供一些额外的价值来寻找性能问题(是服务器上的问题,客户端上的问题......)

processTimings = function (details) {
    var result = {},
        networkPre = calculateTimings('navigationStart', 'requestStart'),
        networkPost = calculateTimings('responseStart', 'responseEnd'),
        network = networkPre + networkPost,
        server = calculateTimings('requestStart', 'responseStart'),
        browser = calculateTimings('responseEnd', 'loadEventEnd'),
        total = network + server + browser;
    ...
};

calculateTimings = function (startIndex, finishIndex) {
    return timingsRaw[finishIndex] - timingsRaw[startIndex];
};

如您所见,这也适用于服务器显示的时间,这解释了为什么您在服务器上有效计算的时间低于 Glimpse 显示的时间。

注意:当然,这些时间的计算方式仅适用于 HTTP 选项卡上 HUD 中显示的时间。例如,“时间轴”选项卡中显示的时间是在服务器上计算的,因为它们显示了服务器上不同处理步骤之间的时间,由于显而易见的原因,浏览器无法对其进行计时。

我希望这回答了你的问题。

于 2013-09-05T21:11:09.373 回答