Javascript looping performances

29th of July 2008

I’ve done a lot of javascript programming recently and more then one time, I had to tweek performance. A nice test suite for performance testing of all (or at least a lot of) ways of looping through an array is located there: http://blogs.sun.com/greimer/resource/loop-test.html. That Blogentry for this awaits you here: http://blogs.sun.com/greimer/entry/best_way_to_code_a

Should be useful from time to time and I really shoud stop using those comfortable for-in-loops…

Addition:

Also is the inverted version of the reversed while loop faster than the ordinary cached for loop.

In short: for (var i=0, len=arr.length; i<len; i++) { } == 5 ms

var i = arr.length-1, j=0; while(--i) {++j;}; == 7 ms

Both tested on my 1.6 Ghz Notebook in battery mode with a simple array with 100,000 entries.

Recent entries

A simple to use/install gallery script

3rd of March 2008

Design called blue tea

22nd of February 2008

Facebook style inputs

17th of February 2008

From prototype to object orientation in javascript

4th of December 2007

Elsewhere being discussed

The Typography of Code
A list of five good fonts to use while programming.
Tools do not designer make
Think about it: do you go to the doctor because of her ability to use a stethoscope? Do you go to an architect because he’s really good with pencil and paper? Do you go to an auto mechanic because he is better with a wrench than you are?

Blogroll

Jeff Croft
Jeff Croft is a web designer based in Seattle. He writes about issue of web design and developements with web standards.
Jeff Croft
Dies ist die Webseite und das Weblog von Gerrit van Aaken. Er schreibt unter anderem auch ueber Webdesign, Typografie und Netzkultur. Wahlspruch: Praegnant & Pragmatisch.
Get83 Photoblog
This is my photoblog where I post some of my photos I took. Most of the time I shoot pictures of buildings and persons in Hamburg.
I love typography
A good weblog about typography from John D Boardley, who is a graphic designer and writer.

 

Information

This site is about the heart of webdesign, webdevelopement and Human-Computer-Interaction.

I am a student of computer science in Hamburg, Germany and am working with the web since several years.

I write what I think can be interesting. My blog is intended to be dual lingual. The most is and will be written in english but if I am lazy, I write in german too.