Created
June 9, 2020 13:29
-
-
Save jokecamp/254be97380838aa5f1787c8a96f1dbe6 to your computer and use it in GitHub Desktop.
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
class Timer { | |
readonly start = performance.now(); | |
constructor(private readonly name: string) {} | |
stop() { | |
const time = performance.now() - this.start; | |
console.log('Timer:', this.name, 'finished in', Math.round(time), 'ms'); | |
} | |
} | |
private t: Timer; | |
// When change detection begins | |
ngDoCheck() { | |
this.t = new Timer('Cardbock block render'); | |
} | |
// When change detection has finished: | |
// child components created, all *ngIfs evaluated | |
ngAfterViewChecked() { | |
this.t.stop(); // Prints the time elapsed to the JS console. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment