Javascript: Check execution time of code : Improve app performance

Basically, almost everybody can code. However, code is not the only ingredient to build great apps. Performance matters a lot. Now a days developers are more concerned about performance which mostly depends on execution speed of code. On the other hand coding standards and readability of codes are important topics too.

Therefore, to overcome the dilemma I have written an example with which one can choose  between two snippets of working codes.

var $elm1 = $('#highlighter_510863 table td:first-child div:first-child code:first-child');
$.each($elm1, function () {
//VM10671:10 time_label: 10.416ms

Or, you could make a function and passing a block of code inside it which you want to measure

function measureTime(functionToExecute){
   var $elm1 = $('#highlighter_510863 table td:first-child div:first-child code:first-child')

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s