Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
instrument performance getEntries
;(function(p){
if (!p) return;
function stash(strMethod)
{
p["__orig_" + strMethod] = p[strMethod];
}
stash("getEntries");
stash("webkitClearResourceTimings");
p.getEntries =
function()
{
return p.__origEntries || p.__orig_getEntries();
};
p.webkitClearResourceTimings =
function()
{
delete p.__origEntries;
p.__orig_webkitClearResourceTimings();
};
p.getEntriesAll =
function()
{
return (p.__savedEntries || []).concat(p.__orig_getEntries());
};
p.addEventListener(
"webkitresourcetimingbufferfull",
function(e)
{
if (!p.__origEntries)
{
var entries = p.__orig_getEntries();
p.__origEntries = entries;
p.__savedEntries = entries;
}
else
{
p.__savedEntries = p.__savedEntries.concat(p.__orig_getEntries());
}
p.__orig_webkitClearResourceTimings();
});
})(window.performance);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment