How to check the number of seconds(or ms) spent inside the particular loop in javascript.
I have a sorting algo implemented in javascript , now I am using bubble sort , I want to use quick sort.
I know in terms of time efficiency Quick sort is good. But I want to calculate the real number of sec or milli sec spent inside the innermost loop.
How do I do in javascript ?
How to check the number of seconds(or ms) spent inside the particular loop in
Share
The simplest method is to compare by Date.
By the way, why don’t you just use the built-in
.sort()(https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/sort) method?