|
|
@@ -338,6 +338,8 @@ App.controller(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function noop() {}
|
|
|
+
|
|
|
function parseCompileResponse(response) {
|
|
|
// keep last url
|
|
|
const lastPdfUrl = $scope.pdf.url
|
|
|
@@ -347,6 +349,8 @@ App.controller(
|
|
|
$scope.pdf.timedout = false
|
|
|
$scope.pdf.failure = false
|
|
|
$scope.pdf.url = null
|
|
|
+ $scope.pdf.updateConsumedBandwidth = noop
|
|
|
+ $scope.pdf.firstRenderDone = noop
|
|
|
$scope.pdf.clsiMaintenance = false
|
|
|
$scope.pdf.tooRecentlyCompiled = false
|
|
|
$scope.pdf.renderingError = false
|
|
|
@@ -396,6 +400,26 @@ App.controller(
|
|
|
// convert the qs hash into a query string and append it
|
|
|
$scope.pdf.url += createQueryString(qs)
|
|
|
|
|
|
+ const {
|
|
|
+ onFirstRenderDone,
|
|
|
+ firstRenderDone,
|
|
|
+ updateConsumedBandwidth,
|
|
|
+ } = trackPDFDownload()
|
|
|
+ $scope.pdf.firstRenderDone = firstRenderDone
|
|
|
+ $scope.pdf.updateConsumedBandwidth = updateConsumedBandwidth
|
|
|
+ const { serviceWorkerMetrics } = response
|
|
|
+
|
|
|
+ onFirstRenderDone.then(({ latencyFetch, latencyRender }) => {
|
|
|
+ sl_console.log(
|
|
|
+ JSON.stringify({
|
|
|
+ latencyFetch,
|
|
|
+ latencyRender,
|
|
|
+ totalBandwidthReportedByPdfJs,
|
|
|
+ serviceWorkerMetrics,
|
|
|
+ })
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
// Save all downloads as files
|
|
|
qs.popupDownload = true
|
|
|
|
|
|
@@ -543,6 +567,33 @@ App.controller(
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ let totalBandwidthReportedByPdfJs = 0
|
|
|
+ function trackPDFDownload() {
|
|
|
+ const t0 = performance.now()
|
|
|
+ let bandwidth = 0
|
|
|
+ function firstRenderDone({ timePDFFetched, timePDFRendered }) {
|
|
|
+ const latencyFetch = timePDFFetched - t0
|
|
|
+ // The renderer does not yield in case the browser tab is hidden.
|
|
|
+ // It will yield when the browser tab is visible again.
|
|
|
+ // This will skew our performance metrics for rendering!
|
|
|
+ const latencyRender = timePDFRendered - t0
|
|
|
+ done({ latencyFetch, latencyRender })
|
|
|
+ }
|
|
|
+ function updateConsumedBandwidth(bytes) {
|
|
|
+ totalBandwidthReportedByPdfJs += bytes - bandwidth
|
|
|
+ bandwidth = bytes
|
|
|
+ }
|
|
|
+ let done
|
|
|
+ const onFirstRenderDone = new Promise(resolve => {
|
|
|
+ done = resolve
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ onFirstRenderDone,
|
|
|
+ firstRenderDone,
|
|
|
+ updateConsumedBandwidth,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function fetchLogs(fileByPath, options) {
|
|
|
let blgFile, chktexFile, logFile
|
|
|
|