JavaScript console.time performance API

JS
S
JavaScript

Simple example of using console.time to measure function calls performance.

1const labelWithTime = `allow origins middleware ${Date.now()}`;
2console.time(labelWithTime);
3Tracking.findOne({ origins: origin }) 
4   .then(res => console.timeEnd(labelWithTime);)
5   .catch(err =>throw err;) 
6
7// Alternative
8const startTime = performance.now();
9const duration = performance.now() - startTime;
10console.log(`someMethodIThinkMightBeSlow took ${duration}ms`);

Created on 10/2/2018