title: Tip to measure performance of a javascript block tip-number: 13 tip-username: manmadareddy tip-username-profile: https://twitter.com/manmadareddy tip-tldr: For quickly measuring performance of a javascript block, we can use the console functions like console.time(label) and console.timeEnd(label)

For quickly measuring performance of a javascript block, we can use the console functions like console.time(label) and console.timeEnd(label)

console.time('Array initialize');var arr = new Array(100),    len = arr.length,    i;for (i = 0; i < len; i++) {    arr[i] = new Object();}console.timeEnd('Array initialize'); // Outputs: Array initialize: 0.711ms

More info: Console object, Javascript benchmarking

Demo: jsfiddle - codepen (outputs in browser console)

Note: As Mozilla suggested don’t use this for production sites, use it for development purposes only.