Created
September 1, 2013 11:06
-
-
Save GavinJoyce/6403776 to your computer and use it in GitHub Desktop.
Run Loop Metrics Bookmarklet
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
javascript:(function(){ | |
var getTimestamp = function() { return new Date().getTime(); }; | |
if (window.performance.now) { | |
getTimestamp = function() { return window.performance.now(); }; | |
} else if (window.performance.webkitNow) { | |
getTimestamp = function() { return window.performance.webkitNow(); }; | |
} | |
var startTime, endTime, loopCount = 0; | |
var onBegin = Ember.run.backburner.options.onBegin; | |
var wrappedOnBegin = function(current) { | |
loopCount++; | |
console.log('run loop: #' + loopCount); | |
startTime = getTimestamp(); | |
onBegin(); | |
}; | |
Ember.run.backburner.options.onBegin = wrappedOnBegin; | |
var onEnd = Ember.run.backburner.options.onEnd; | |
var wrappedOnEnd = function(current) { | |
onEnd(); | |
endTime = getTimestamp(); | |
console.log('loop duration: ' + (endTime - startTime) + 'ms'); | |
}; | |
Ember.run.backburner.options.onEnd = wrappedOnEnd; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment