473,748 Members | 9,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Internet Explorer vs. Firefox javascript array performance

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;
}

Oct 10 '06 #1
3 9844

go****@grepit.c om wrote:
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.
Did that make any difference?

Has anyone got experience of this and have any suggestions for me to
try out?
For me, the following is marginally faster, but I don't think it will
give you the kind of gains you are after:

var ItemArray = [];
var start = new Date().getTime( );
var i = 5000;
while (i--) {
ItemArray[i] = new Item("Field1", "Field2", "Field3");
}

var end = new Date().getTime( );

alert("Test took " + ((end - start) / 1000) + " seconds");

function Item(Field1, Field2, Field3)
{
this.Field = [Field1, Field2, Field3];
this.Flags = [true, false];
}
--
Rob

Oct 10 '06 #2
Thanks for your suggestions.

You are right in that the suggestions will improve performance, but not
give the order of magnitude I need to find.

I found that I could roughly halve the Internet Explorer 6 processing
time by not having an array of objects, but just using a 2 dimensional
array.

One of the downsides to this approach, is that I lost the object
structure which made the code easy to understand through being able to
reference "Item[n].Field[n]" and "Item[n].Flags[n]" - ending up with
"Item[n][m]" type references.

I guess I am just amazed at the IE/Firefox performance diffential. One
thought I has was that maybe Microsoft are more focused on getting
solutions built with server-side technology, rather than building a
browser that can handle the type of processing - that's where the
revenue is I guess ...

Oct 10 '06 #3
VK
So Gecko does cache dispid's... No wonder with their JavaScript engine
dependance for the entire browser - yet it's nice to know for sure
without digging in C-sources.

In application to IE IDispatcher doesn't cache dispid's, other words
every time it needs a reference to an object/member it takes the string
name ("Item" in your case) and searches for the memory address in the
names table. Every single of 10,000 times...

So you can improve the performance by not forcing IDispatcher to go for
external references. It seems slow down Firefox for just a little bit
(I don't know why) but on my test machines it shows 150% performance
gain for IE:

<script type="text/javascript">
var ItemArray1 = new Array(10000);

now = new Date;
start = now.getTime();

for (Count=0; Count<10000; Count++) {
ItemArray1[Count] = {
'Field' : [0,1,2]
, 'Flags' : [true, false]
};
}

now = new Date;
end = now.getTime();

alert("Test took " + ((end - start) / 1000) + " seconds");
</script>

P.S. "Second's fractions hunters" :-) : please do not take it as a
stimulus to drop OOP immediately on IE :-) But for extrim cases
(10,000...100,0 00... objects to create in one loop) that can be
something to takes into consideration.

Oct 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8539
by: Jason Keirstead | last post by:
Is there a way I can add a setter/getter to the HTMLElement prototype in internet explorer? This, for example, works fine in Mozilla: HTMLElement.prototype.__defineSetter__("foobar", function (sFoobar) { alert( sFoobar ); });
11
1771
by: dhplank | last post by:
Hello everyone, I've developed a calendar program in javascript, and up until now I've done most of my testing using Mozilla and Firefox. Everything works fine, but when I try to use Internet Explorer my response time is sometimes 50 times slower than using Mozilla. I know I haven't given you much to go by, but I'm not looking for an answer so much as an approach to debugging the problem. For example, does anyone here know of a good...
11
2026
by: GHUM | last post by:
Hello, I created some rather complex Intranet Application, using lots of JavaScript, DOM-Maninpulation and XMLHTTPRequest communication. I developed on FireFox, with the excellent firebug ... every misstake was given back with a fine, fine traceback; exactly pointing to the code at error. My code runs fine on FireFox and Opera.
5
1716
by: gray_slp | last post by:
I am designing a web survey using surveymonkey.com and discovered I could use javascript to modify their standard question formats much the same as can be done in myspace. I used this feature to insert a weight converter into my survey. Unfortunately this script works fine in firefox v.2 but does not cooperate with the surveymonkey software when used with internet explorer v.6. Can someone explain to me in simple terms why the script...
1
2343
by: gray_slp | last post by:
I am designing a web survey using surveymonkey.com and discovered I could use javascript to modify their standard question formats much the same as can be done in myspace. I used this feature to insert a weight converter I found into my survey. Unfortunately this script works fine in firefox v.2 but does not cooperate with the surveymonkey software when used with internet explorer v.6. In IE, the script makes it so that I am unable to...
26
2288
by: Prisoner at War | last post by:
Hi, All: I have a JavaScript search engine that always causes MSIE 7 to do a top-of-page security "warning" (that top-of-page-bar, and not an "alert" )...but other websites' JavaScripts do not trigger that...what's going on? When I visit other JavaScript sites there's no warning and the scripts work fine, but mine (it's still under construction, offline) occasions that warning and I have to manually allow MSIE to run JavaScript every...
1
4848
by: avpkills2002 | last post by:
I seem to be getting this weird problem in Internet explorer. I have written a code for parsing a XML file and displaying the output. The code works perfectly fine with ffx(Firefox).However is not working in Internet Explorer.(I m using Internet Explorer 6.0). The code is as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
2
3153
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error message as in alert box as " Internet Explorer cannot open the Internet site http://google.citycarrentals.com.au/viewalllocations.php . Operation aborted". It is working in Mozilla . Here i mentioned my code . I am facing this problem several...
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.