Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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');
- }
- }
- const t = new Timer('Some label');
- // Code to benchmark
- t.stop(); // Prints the time elapsed to the JS console.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement