Chromium Code Reviews| Index: Source/devtools/front_end/HAREntry.js |
| diff --git a/Source/devtools/front_end/HAREntry.js b/Source/devtools/front_end/HAREntry.js |
| index 51f996e5f2a90c0a70f8291a627b0eb82e7601a8..9f732534996de9006ede202c35e229251ca3b510 100644 |
| --- a/Source/devtools/front_end/HAREntry.js |
| +++ b/Source/devtools/front_end/HAREntry.js |
| @@ -49,14 +49,18 @@ WebInspector.HAREntry.prototype = { |
| */ |
| build: function() |
| { |
| - var entry = { |
| + var timings = this._buildTimings(); |
| + var time = Math.max(timings.blocked, 0) + Math.max(timings.dns, 0) + Math.max(timings.connect, 0) + Math.max(timings.send, 0) + Math.max(timings.wait, 0) + Math.max(timings.receive, 0); |
|
caseq
2013/08/30 15:12:53
So if we lost some time due to imperfect instrumen
eustas
2013/09/13 15:10:36
Done.
|
| + |
| + var entry = { |
| startedDateTime: new Date(this._request.startTime * 1000), |
| - time: WebInspector.HAREntry._toMilliseconds(this._request.duration), |
| + time: time, |
| request: this._buildRequest(), |
| response: this._buildResponse(), |
| cache: { }, // Not supported yet. |
| - timings: this._buildTimings() |
| + timings: timings |
| }; |
| + |
| if (this._request.connectionId) |
| entry.connection = String(this._request.connectionId); |
| var page = WebInspector.networkLog.pageLoadForRequest(this._request); |
| @@ -125,23 +129,42 @@ WebInspector.HAREntry.prototype = { |
| */ |
| _buildTimings: function() |
| { |
| - var waitForConnection = this._interval("connectStart", "connectEnd"); |
| - var blocked = 0; |
| - var connect = -1; |
| + // Order of events: request_start = 0, [proxy], [dns], [connect [ssl]], [send], receive_headers_end |
| + // HAR 'blocked' time is time before first network activity. |
| + // The rest time gaps will be classified as '_other'. |
| + |
| + var dns = this._interval("dnsStart", "dnsEnd"); |
| + var send = this._interval("sendStart", "sendEnd"); |
| + var wait = this._interval("sendEnd", "receiveHeadersEnd"); |
| + var receive = WebInspector.HAREntry._toMilliseconds(this._request.receiveDuration); |
| + var connect = this._request.connectionReused ? -1 : this._interval("connectStart", "connectEnd"); |
| + |
| + var blocked = -1; |
| + var timing = this._request.timing; |
| + if (timing) { |
| + var events = ["dnsStart", "connectStart", "sendStart"]; |
| + var times = []; |
| + for (var i = 0; i < events.length; ++i) { |
| + var time = timing[events[i]]; |
| + if (typeof time === "number" && time !== -1) |
|
caseq
2013/08/30 15:12:53
Note that if (time >= 0) times.push(time) would wo
eustas
2013/09/13 15:10:36
Done.
|
| + times.push(time); |
| + } |
| + if (times.length) |
| + blocked = Math.min.apply(null, times); |
|
caseq
2013/08/30 15:12:53
So what happened to the old logic of "if connectio
eustas
2013/09/13 15:10:36
It is baked into glue.
|
| + } |
| - if (this._request.connectionReused) |
| - blocked = waitForConnection; |
| - else |
| - connect = waitForConnection; |
| + var total = WebInspector.HAREntry._toMilliseconds(this._request.duration); |
| + var other = total - Math.max(blocked, 0) - Math.max(dns, 0) - Math.max(connect, 0) - Math.max(send, 0) - Math.max(wait, 0) - Math.max(receive, 0); |
| return { |
| - blocked: blocked, |
| - dns: this._interval("dnsStart", "dnsEnd"), |
| - connect: connect, |
| - send: this._interval("sendStart", "sendEnd"), |
| - wait: this._interval("sendEnd", "receiveHeadersEnd"), |
| - receive: WebInspector.HAREntry._toMilliseconds(this._request.receiveDuration), |
| - ssl: this._interval("sslStart", "sslEnd") |
| + blocked: Math.round(blocked), |
| + dns: Math.round(dns), |
| + connect: Math.round(connect), |
| + send: Math.round(send), |
| + wait: Math.round(wait), |
| + receive: Math.round(receive), |
| + ssl: Math.round(this._interval("sslStart", "sslEnd")), |
| + _other: Math.round(other) |
| }; |
| }, |
| @@ -214,7 +237,7 @@ WebInspector.HAREntry.prototype = { |
| if (!timing) |
| return -1; |
| var startTime = timing[start]; |
| - return typeof startTime !== "number" || startTime === -1 ? -1 : Math.round(timing[end] - startTime); |
| + return typeof startTime !== "number" || startTime === -1 ? -1 : (timing[end] - startTime); |
|
caseq
2013/08/30 15:12:53
Please remove redundant parenthesis.
eustas
2013/09/13 15:10:36
Done.
|
| }, |
| /** |
| @@ -252,7 +275,7 @@ WebInspector.HAREntry.prototype = { |
| */ |
| WebInspector.HAREntry._toMilliseconds = function(time) |
| { |
| - return time === -1 ? -1 : Math.round(time * 1000); |
| + return time === -1 ? -1 : (time * 1000); |
|
caseq
2013/08/30 15:12:53
Ditto.
eustas
2013/09/13 15:10:36
Done.
|
| } |
| /** |
| @@ -341,7 +364,7 @@ WebInspector.HARLog.prototype = { |
| var startTime = page.startTime; |
| if (time === -1 || startTime === -1) |
| return -1; |
| - return WebInspector.HAREntry._toMilliseconds(time - startTime); |
| + return Math.round(WebInspector.HAREntry._toMilliseconds(time - startTime)); |
| } |
| } |