April 29th, 2017

IE performance hints

In Internet Explorer, memory usage has a severe impact on performance. As memory utilisation rise, performance decrease. Also in comparing strings vs comparing variables huge benefits can be found. Here is a simple test that illustrates the behavior:

function test() {
var i;
var ic0 = 100000; // change this to affect memory use
var ic1 = 100000;
var o = {};
var s0=”test”;
var s1 =”test”;
var g,d0,d1,r0,r1
// 1: use up some memory
for ( i = 0 ; i < ic0 ; i++ ) {
o[i] = 1;
}
// 2: compare run 0
d0 = new Date();
for( i = 0 ; i < ic1 ;i++ ) {
g = (s0==”test”);
}
r0 = new Date() - d0;
// 3: compare run 1
d1 = new Date();
for( i = 0 ; i < ic1 ;i++) {
g = (s0==s1);
}
r1 = new Date() - d1;
alert(
“compare run 0 : ” + r0 + “ms\n” +
“compare run 1 : ” + r1 + “ms”
);
}
test();

4 Responses to 'IE performance hints'

  1. 1Liam
    March 24th, 2006 at 10:21 pm

    Hi,

    I have been playing with this as it seems to be a very significant problem.

    I tried changing the scope of ‘o’ (make it global, create it after the pre-compile of the functions), but without benefit.

    I tried a static array, but at 100,000 elements IE bombed with an ‘out of memory’ error (so MUCH worse. And at 10k performance was still WORSE than a dynamic array.

    Then I tried doing it as a nested array (5 deep by ten elements). Performance about half that of a single dimensioned array.

    As I already have an application that has static array of about 10,000 elements and as each element of the array is a string I was very surprised at seeing this. at 10K I have not *noticed* any performance hit.

    Clearly it seems that the number of elements is more significant than the size of each element.

    The real question then is: is there any way to get around this issue?

    Are large objects any better?

    Would a very large string along with methods to extract the effective element be better (strings are usually pretty lame, but maybe a single static string would be good here)?

    I shall continue to play in the hope of finding a better (more performant) way to represent large data object, but any pointers that you have would be appreciated.

    After all if you *need* a 100K element array, then you need it!

    A really interesting snippet. Good to see some truly original info in all the other dross of closure memory leaks and other pointless IE ‘hate mail’.

    Nice one.

    As an aside, does anyone know if IE7 is also affected (afflicted;-) by this issue?

    Liam


  2. 2John Burgman
    July 4th, 2006 at 9:38 am

    Unfortunately, I have spent 2 full weeks discovering this problem and just how extensive (bad) it is. Firefox shows little or no degradation in performance after loading a large chunk of data but IE shows a remarkable drop in response.

    As a FYI to other users, what I have done in the past and what I am trying to do now is to prepare data in advance of loading it. That is, create a DIV, populate it with a table of information then use the DIV’s own scrolling to view the results. Unfortunately, the question will be how to do this all within the Bindows framework.

    Good luck to everybody. It’s a moments like this, facing the unsolvable stumbling block when I think I should have gone into another line of work.


  3. 3collector
    April 8th, 2008 at 7:58 am

    Read somewhere that IE has performance problems when adding to ‘document’. Use global vars instead.

    This one is slower:
    for (i=1; i<10000; i++) {
    document.something += 1;
    }

    this is faster:
    var something;
    for (i=1; i<10000; i++) {
    something += 1;
    }


  4. 4langue
    May 11th, 2009 at 3:39 am

    Did not notice a difference on IE7


Leave a Response

Imhotep theme designed by Chris Lin. Proudly powered by Wordpress.
XHTML | CSS | RSS | Comments RSS