JavaScript Performance Assessment

background:

I was looking for a link for a link, or perhaps a tool to help you theoretically evaluate the effectiveness (cost of resources) of your JavaScript. A lot of great debugging software has appeared in this search, but I cannot find anything that helps me optimize the code using less resource-intensive methods.

Question:

Is there any resource (online guide, list, database, book, anything) or maybe some software (web interface, browser plugin, IDE extension) that will help you optimize your JavaScript? / p>

Example:

innerTextin IE / textContentin Firefox requires much less resources than innerHTMLin any browser.

This is kind of common sense, because it is less powerful, but there are other comparisons that I hear daily, and I can’t check if they are really better optimized for the code or more efficient, and even if I couldn’t check it!

Any ideas?

+5
source share
5 answers

The usual way to evaluate Javascript is to estimate the amount of time it takes to execute a set of code:

var begin = new Date().getTime();
//do stuff
console.debug( new Date().getTime() - begin );

However, in IE there are some problems. if a script takes <15ms to run, IE returns 0ms as the result.

Different javascript libraries have test frameworks that help evaluate the speed of your code. Dojo Testing Structure is called DOH.

Firebug FireUnit, , , Big O , .

Resig JSConf JS:

Javascript - John Resig

FireUnit rundown

+6

, strife25, firebug - . :

console.time("Your timer name");
//Execute some javascript
console.timeEnd("Your timer name");

. alt text http://aquate.us/u/62232567893647972047.jpg

- 30 .: (

+8

Firebug:

console.time("timer-name");

console.timeEnd("timer-name");

.

+3

Firebug's Profile tool is great for measuring javascript performance. It shows you all the bottlenecks in your code in a function by function, showing which one had the longest average time, most calls, etc.

+1
source

The profiler in IE8 is amazing. It gives you a tree view along with inclusive time (in ms)

+1
source

All Articles