Skip to content

Commit

Permalink
Track LongTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Sep 29, 2017
1 parent 28024a6 commit ccc8b1a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion perfbar.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ var UW = unsafeWindow;
//
// Local Members
//
var initialized = false;

// total frames seen
var totalFrames = 0;
Expand All @@ -438,6 +439,11 @@ var UW = unsafeWindow;
// rage clicks
var rageClicks = [];

if (!BOOMR.longTasks) {
BOOMR.longTasks = [];
}
var longTasks = BOOMR.longTasks;

/**
* requestAnimationFrame callback
*/
Expand Down Expand Up @@ -507,6 +513,26 @@ var UW = unsafeWindow;
});
}

function onPerformanceObserver(list) {
var entries = list.getEntries();
Array.prototype.push.apply(longTasks, entries);

if (BOOMR.sendMetric) {
BOOMR.sendMetric("LongTasks", entries.length);
}

// add to the timeline
if (initialized) {
tb.update("Realtime", "LongTasks", longTasks.length, {
color: "red"
});
}
}

// PerformanceObserver
var perfObserver = new UW.PerformanceObserver(onPerformanceObserver);
perfObserver.observe({ entryTypes: ["longtask"] });

// start out the first frame
window.requestAnimationFrame(frame);

Expand Down Expand Up @@ -4224,7 +4250,7 @@ function initEmbeddedBoomerang() {
t.register("longtask", COMPRESS_MODE_SMALL_NUMBERS);

// Long Tasks array
var longTasks = [];
var longTasks = BOOMR.longTasks || [];

// whether or not we're enabled
var enabled = true;
Expand Down

0 comments on commit ccc8b1a

Please sign in to comment.