Last active
September 3, 2019 15:32
-
-
Save 321hendrik/db61386b1af1abd25190e447d10b7120 to your computer and use it in GitHub Desktop.
console.time emulation for appcelerator titanium apps
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
var timers = {}; | |
Ti.App.time = function(key) { | |
console.error('timer started:', key); | |
if (timers[key]) { | |
Ti.App.timeEnd(key); | |
} | |
timers[key] = new Date().getTime(); | |
}; | |
Ti.App.timeEnd = function(key) { | |
if (!timers[key]) { | |
return; | |
} | |
console.error(key + ':', (new Date().getTime() - timers[key]) + 'ms'); | |
delete timers[key]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment