Created
March 1, 2017 13:14
-
-
Save kemsky/7fbb9fc33113ce66779c1dc511e5d136 to your computer and use it in GitHub Desktop.
Measure and report Angular 2 change detection time
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
const detectChanges = changeDetector['_view']['detectChanges']; | |
let detect = 0; | |
let title = document.getElementsByTagName('title')[0] as HTMLTitleElement; | |
changeDetector['_view']['detectChanges'] = () => { | |
detect++; | |
const start = getTimer(); | |
detectChanges.apply(changeDetector['_view']); | |
let time = (getTimer() - start); | |
let text = ` [${detect}] ${time.toFixed(2)} ms`; | |
title.text = text; | |
if(time > 25) | |
{ | |
console.warn(text); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment