Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created September 10, 2012 17:20
Show Gist options
  • Save tmcw/3692271 to your computer and use it in GitHub Desktop.
Save tmcw/3692271 to your computer and use it in GitHub Desktop.
Spy on requests through MM and call a callback with ms inflight
function spy(layer, callback) {
var inflight = {};
var rt = layer.requestManager.requestTile;
layer.requestManager.requestTile = function() {
inflight[arguments[0]] = +new Date();
rt.apply(layer.requestManager, arguments);
};
layer.requestManager.addCallback('requestcomplete', function(s, img) {
callback(+new Date() - inflight[img.id]);
delete inflight[img.id];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment