Skip to content

Instantly share code, notes, and snippets.

@cvazac
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvazac/fe2666834e7f157a1fe7 to your computer and use it in GitHub Desktop.
Save cvazac/fe2666834e7f157a1fe7 to your computer and use it in GitHub Desktop.
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