Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nicjansma/perfbar.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Sep 28, 2017
2 parents 8e79962 + 47afef2 commit 1eff6e3
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion perfbar.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,30 @@ var UW = unsafeWindow;
metricUpdated[name] = true;
}
}
function updateReq() {
let edgeTime = 0
for (const {name: url, serverTiming} of performance.getEntriesByType('navigation')) {
for (const {name, metric, duration, value} of serverTiming) {
if (['cret', 'ctt'].indexOf(name || metric) !== -1) {
edgeTime += (typeof duration !== 'undefined' ? duration : value)
}
}
}

if (!edgeTime) {
updateTiming("Req", performance.timing.requestStart, performance.timing.responseStart);
} else {
tb.update("Timings", "Req", `${performance.timing.responseStart - performance.timing.requestStart} (${edgeTime})`)
}
}

function init() {
tb.register("Timings", ["DNS", "TCP", "Req", "Res"]);

// these should all be ready on startup
updateTiming("DNS", performance.timing.domainLookupStart, performance.timing.domainLookupEnd);
updateTiming("TCP", performance.timing.connectStart, performance.timing.connectEnd);
updateTiming("Req", performance.timing.requestStart, performance.timing.responseStart);
updateReq()
updateTiming("Res", performance.timing.responseStart, performance.timing.responseEnd);
}

Expand Down Expand Up @@ -473,6 +489,18 @@ var UW = unsafeWindow;
// TODO: Tooltips
tb.register("Resources", ["#", "KB", "TAO", "Cached", "Offload %", "Offload KB", "Edge"]);

document.addEventListener("onBoomerangLoaded", function({detail: {BOOMR}}) {
BOOMR.subscribe("onbeacon", function({t_other}) {
t_other.split(',').find(function(section) {
var data = section.split('|')
if (data[0] === 'custom0') {
tb.update("Resources" ,"Edge", data[1])
return true
}
})
})
})

updateResources();
}

Expand Down

0 comments on commit 1eff6e3

Please sign in to comment.