Last active
August 29, 2015 14:21
-
-
Save cvazac/fe2666834e7f157a1fe7 to your computer and use it in GitHub Desktop.
instrument performance getEntries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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