Skip to content

Commit

Permalink
Merge pull request #30 from Microsoft/albulank/mathfix
Browse files Browse the repository at this point in the history
Measuring domProcessing from responseEnd
  • Loading branch information
AlexBulankou committed Jul 15, 2015
2 parents 0a8d140 + c355fb2 commit de6a1b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Expand Up @@ -56,7 +56,6 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
timing.requestStart = 11;
timing.responseStart = 30;
timing.responseEnd = 42;
timing.domLoading = 52;
timing.loadEventEnd = 60;

var timingSpy = sinon.stub(Microsoft.ApplicationInsights.Telemetry.PageViewPerformance, "getPerformanceTiming",() => {
Expand All @@ -73,7 +72,7 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
Assert.equal(Microsoft.ApplicationInsights.Util.msToTimeSpan(9), data.networkConnect);
Assert.equal(Microsoft.ApplicationInsights.Util.msToTimeSpan(19), data.sentRequest);
Assert.equal(Microsoft.ApplicationInsights.Util.msToTimeSpan(12), data.receivedResponse);
Assert.equal(Microsoft.ApplicationInsights.Util.msToTimeSpan(8), data.domProcessing);
Assert.equal(Microsoft.ApplicationInsights.Util.msToTimeSpan(18), data.domProcessing);

timingSpy.restore();
}
Expand All @@ -89,7 +88,6 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
timing.requestStart = 11;
timing.responseStart = 30;
timing.responseEnd = 42;
timing.domLoading = 52;
timing.loadEventEnd = 60;

var timingSpy = sinon.stub(Microsoft.ApplicationInsights.Telemetry.PageViewPerformance, "getPerformanceTiming",() => {
Expand All @@ -111,7 +109,7 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
Assert.equal(undefined, data.receivedResponse);
Assert.equal(undefined, data.domProcessing);

Assert.equal("client performance math error:59 < 39 + 19 + 12 + 8", actualLoggedMessage);
Assert.equal("client performance math error:59 < 39 + 19 + 12 + 18", actualLoggedMessage);

timingSpy.restore();
loggingSpy.restore();
Expand Down
10 changes: 5 additions & 5 deletions JavaScript/JavaScriptSDK/Telemetry/PageViewPerformance.ts
Expand Up @@ -44,18 +44,18 @@ module Microsoft.ApplicationInsights.Telemetry {
* | ||-requestStart
* | || |-responseStart
* | || | |-responseEnd
* | || | ||-domLoading
* | || | || |-loadEventEnd
* |---network---||---request---|---response---||---dom---|
* |--------------------------total-----------------------|
* | || | |
* | || | | |-loadEventEnd
* |---network---||---request---|---response---|---dom---|
* |--------------------------total----------------------|
*/
var timing = PageViewPerformance.getPerformanceTiming();
if (timing) {
var total = PageViewPerformance.getDuration(timing.navigationStart, timing.loadEventEnd);
var network = PageViewPerformance.getDuration(timing.navigationStart, timing.connectEnd);
var request = PageViewPerformance.getDuration(timing.requestStart, timing.responseStart);
var response = PageViewPerformance.getDuration(timing.responseStart, timing.responseEnd);
var dom = PageViewPerformance.getDuration(timing.domLoading, timing.loadEventEnd);
var dom = PageViewPerformance.getDuration(timing.responseEnd, timing.loadEventEnd);


if (total == 0) {
Expand Down

0 comments on commit de6a1b3

Please sign in to comment.