views:

63

answers:

2

Recently, I've heard a number of different people lamenting the speed differences in IE versus pretty well every other browser when it comes to using JavaScript to manipulate the DOM.

I thought I'd put together a tiny little script to see what the differences really were, but I think I'm looking at the wrong problem as IE performs as well as or better with the tests I've developed.

Does anyone have some JavaScript laying around that would be good at illustrating the differences in speed of IE versus other browsers, specifically code that manipulates the DOM?

I'd like to test some optimization techniques, but I need a good test case first.

Edit: Sorry, here is my tiny little throwaway script:

  var counter = 0; // Global element counter

  function addCheckBoxes(){
    var container = document.getElementById('container');
    var newBox = document.getElementById('check1').cloneNode(true);
    newBox.id = '';
    container.appendChild(newBox);
  }

  function addLotsOfBoxes(){
    var thistime = new Date();
    for(i=0; i < 8000; i++)
    {
      addCheckBoxes();
    }   
    var thattime = new Date();
    var timediff = thattime - thistime;
    alert(timediff);
  }
+2  A: 

I have a few demos that have been thrown around in the past

But there are a huge number at Nihilogic (especially this one)

[edit(olliej): whoops, i just realised that none of these will work in IE :-( ]

olliej
I don't know how to mark multiple answers as correct; and evidently I don't have enough points to upvote both answers :(
icey
+3  A: 

The dromaeo benchmark, by mozilla should be a good test of dom manipulation performance.

There are also the sunspider benchmarks, however those do not touch the DOM at all.

Chi
I don't know how to mark multiple answers as correct; and evidently I don't have enough points to upvote both answers :(
icey
The issue with dromaeo is that it is badly implemented -- for instance there are a few tests that are run multiple times and the average time is calculated (which is okay) but the DOM is not cleared between runs, so in fast DOM implementations the later runs start using huge amounts of memory resulting in huge performance reduction really quickly. If you run webkit based browsers in this you start seeing huge variances in the DOM tests because of this. :-/
olliej