G
I am trying to complete a javascript application and am having problems
with code similar to that show below.
Much testing has shown that Firefox finishes the code shown in around
0.25 secs but Internet Explorer 6 takes a massive 3.5 secs! Internet
Explorer 7 gets it down to around 2 seconds - but that's still 8 times
slower than Firefox and way unacceptable for my userbase.
Looking through the newsgroups there is some discussion around the
differences between the way the two browsers handle arrays - but a
performance differential such as this is just unbelievably dismal.
Unfortunately I need to continue to use arrays of objects and have to
support the Internet Explorer client base. I have already added
specification of the array size and also removed the use of array
"push"ing - flattening the array is not really an option.
Has anyone got experience of this and have any suggestions for me to
try out?
Many thanks,
// JavaScript Document
var ItemArray = new Array(10000);
now = new Date;
start = now.getTime();
for (Count=0; Count<10000; Count++)
ItemArray[Count] = new Item("Field1", "Field2", "Field3");
now = new Date;
end = now.getTime();
alert("Test took " + ((end - start) / 1000) + " seconds");
function Item(Field1, Field2, Field3)
{
this.Field = new Array(3);
this.Field[0] = Field1;
this.Field[1] = Field2;
this.Field[2] = Field3;
this.Flags = new Array(2);
this.Flags[0] = true;
this.Flags[1] = false;
}
with code similar to that show below.
Much testing has shown that Firefox finishes the code shown in around
0.25 secs but Internet Explorer 6 takes a massive 3.5 secs! Internet
Explorer 7 gets it down to around 2 seconds - but that's still 8 times
slower than Firefox and way unacceptable for my userbase.
Looking through the newsgroups there is some discussion around the
differences between the way the two browsers handle arrays - but a
performance differential such as this is just unbelievably dismal.
Unfortunately I need to continue to use arrays of objects and have to
support the Internet Explorer client base. I have already added
specification of the array size and also removed the use of array
"push"ing - flattening the array is not really an option.
Has anyone got experience of this and have any suggestions for me to
try out?
Many thanks,
// JavaScript Document
var ItemArray = new Array(10000);
now = new Date;
start = now.getTime();
for (Count=0; Count<10000; Count++)
ItemArray[Count] = new Item("Field1", "Field2", "Field3");
now = new Date;
end = now.getTime();
alert("Test took " + ((end - start) / 1000) + " seconds");
function Item(Field1, Field2, Field3)
{
this.Field = new Array(3);
this.Field[0] = Field1;
this.Field[1] = Field2;
this.Field[2] = Field3;
this.Flags = new Array(2);
this.Flags[0] = true;
this.Flags[1] = false;
}