I have an use case where I need to get the total number of Javascript lines executed when my web page is loading.
The problem I am facing is that the browser throws an alert when a certain number of JS execution exceed ( 5 million I think in case of IE ) and the page gets hanged.
I used the profiler available in IE Developers tool bar,but it gives me the total number of JS functions called but not the total number/count of lines executed.
Any help is appreciated.
Thanks
This may help:
http://www-archive.mozilla.org/performance/jsprofiler.html
The first line specifies the js file from which times were gathered. Each line below that is of the format: [A, B] C {D-E} F {G, H, I}
D -> Base line number of the function in the JS file
E -> Extent (last) line number of the function in the JS file
First of all, you should really redesign your code; 5 million statements without handing control back to the browser is by all means a lot of code, imagine how mobile browsers will struggle with it.
One way to find out how many statements are executed is by instrumenting your code, adding one statement for each statement in your code to count the number of times it was executed, effectively doubling up the number of statements in your code.
There are also code coverage tools that can run inside the browser without having to instrument your code at all; Googling for "javascript code coverage" gives a fair amount of browser extensions that you could use, such as hrtimer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With