473,769 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Huge arrays - speed problems?

Are there any speed issues in javascript with having really large
arrays? I know if the array gets large enough, bandwidth and download
time can be an issue, but does it take inordinate amounts of time to
access a really large array?
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #1
10 7045
Fabian hu kiteb:
Are there any speed issues in javascript with having really large
arrays? I know if the array gets large enough, bandwidth and download
time can be an issue, but does it take inordinate amounts of time to
access a really large array?


Specifically, inordiante amounts of processor/disk access time.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #2
Lee
Fabian said:

Are there any speed issues in javascript with having really large
arrays? I know if the array gets large enough, bandwidth and download
time can be an issue, but does it take inordinate amounts of time to
access a really large array?


That depends on what you consider to be "really large".

I wrote a simple script that creates an array of a given size,
loops through the array setting each element equal to 1,
<notes how long this has taken>
then loops through the array, adding up all those 1's, and
<notes how long this has taken>

I ran this in Netscape 7.1 and IE 6, with arrays of size
10,000, 100,000 and 1,000,000 elements, recording the time
in seconds to initialize the array, and then to access each
element (totalling them). All of the times were near zero
except at 1 million elements. That took Netscape 3 seconds
to initialize and 2 seconds to access, and IE 20 seconds(!)
to initialize but also 2 seconds to access all elements.

This was on a relatively slow processor.

Jul 20 '05 #3
Lee hu kiteb:
Fabian said:

Are there any speed issues in javascript with having really large
arrays? I know if the array gets large enough, bandwidth and download
time can be an issue, but does it take inordinate amounts of time to
access a really large array?


That depends on what you consider to be "really large".

I wrote a simple script that creates an array of a given size,
loops through the array setting each element equal to 1,
<notes how long this has taken>
then loops through the array, adding up all those 1's, and
<notes how long this has taken>

I ran this in Netscape 7.1 and IE 6, with arrays of size
10,000, 100,000 and 1,000,000 elements, recording the time
in seconds to initialize the array, and then to access each
element (totalling them). All of the times were near zero
except at 1 million elements. That took Netscape 3 seconds
to initialize and 2 seconds to access, and IE 20 seconds(!)
to initialize but also 2 seconds to access all elements.


The maximum array size I was envisioning was going to be 10,000 by
20,000. I originally envisioned single character text, but there is no
functional reason they couldn't be nunbers, and numbers probably work
better in js anyway. Nice to know I am unlikely to hit any speed
barriers here.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #4
rf

"Fabian" <la****@hotmail .com> wrote in message
news:bo******** *****@ID-174912.news.uni-berlin.de...
Lee hu kiteb:
Fabian said:

Are there any speed issues in javascript with having really large
arrays? I know if the array gets large enough, bandwidth and download
time can be an issue, but does it take inordinate amounts of time to
access a really large array?


That depends on what you consider to be "really large".

I wrote a simple script that creates an array of a given size,
loops through the array setting each element equal to 1,
<notes how long this has taken>
then loops through the array, adding up all those 1's, and
<notes how long this has taken>

I ran this in Netscape 7.1 and IE 6, with arrays of size
10,000, 100,000 and 1,000,000 elements, recording the time
in seconds to initialize the array, and then to access each
element (totalling them). All of the times were near zero
except at 1 million elements. That took Netscape 3 seconds
to initialize and 2 seconds to access, and IE 20 seconds(!)
to initialize but also 2 seconds to access all elements.


The maximum array size I was envisioning was going to be 10,000 by
20,000. I originally envisioned single character text, but there is no
functional reason they couldn't be nunbers, and numbers probably work
better in js anyway. Nice to know I am unlikely to hit any speed
barriers here.


GAK. 10,000 by 20,000. Hmmm lets see, even if this were a character array
that would be <calculates /> a 190+ megabyte array. Any computer with less
than half a gig of memory would grind to a halt in the paging subsystem.

What *are* you trying to do?

Cheers
Richard.
Jul 20 '05 #5
rf hu kiteb:
"Fabian" <la****@hotmail .com> wrote in message
news:bo******** *****@ID-174912.news.uni-berlin.de...
Lee hu kiteb:
Fabian said:

Are there any speed issues in javascript with having really large
arrays? I know if the array gets large enough, bandwidth and
download time can be an issue, but does it take inordinate amounts
of time to access a really large array?

That depends on what you consider to be "really large".

I wrote a simple script that creates an array of a given size,
loops through the array setting each element equal to 1,
<notes how long this has taken>
then loops through the array, adding up all those 1's, and
<notes how long this has taken>

I ran this in Netscape 7.1 and IE 6, with arrays of size
10,000, 100,000 and 1,000,000 elements, recording the time
in seconds to initialize the array, and then to access each
element (totalling them). All of the times were near zero
except at 1 million elements. That took Netscape 3 seconds
to initialize and 2 seconds to access, and IE 20 seconds(!)
to initialize but also 2 seconds to access all elements.


The maximum array size I was envisioning was going to be 10,000 by
20,000. I originally envisioned single character text, but there is
no functional reason they couldn't be nunbers, and numbers probably
work better in js anyway. Nice to know I am unlikely to hit any speed
barriers here.


GAK. 10,000 by 20,000. Hmmm lets see, even if this were a character
array that would be <calculates /> a 190+ megabyte array. Any
computer with less than half a gig of memory would grind to a halt in
the paging subsystem.

What *are* you trying to do?


That was the maximum *theoretical* size. I would be somewhat surprised
if i ever actually used an array that size. Basically, I was thinking of
virtually dividing the world's surace into 3 mile squares, then creating
a pseudo-virtual reality.

Oh well.

Lets see. 100k^0.5 is 316. I guess I can do something with a grid that
size.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #6
"rf" <ma**********@t he.time> wrote in message
news:5u******** ************@ne ws-server.bigpond. net.au...
<snip>
GAK. 10,000 by 20,000. Hmmm lets see, even if this were a
character array that would be <calculates /> a 190+ megabyte
array. Any computer with less than half a gig of memory
would grind to a halt in the paging subsystem.

<snip>

Even that seems an optimistic calculation as JavaScript has no character
data type, and if it did it would be a two byte Unicode character.

I would think that storing a single character would require JavaScript
to use a string value, probably implemented as a minimum of a 32 bit
unsigned integer describing the length plus the string date (2 bytes
minimum for a char), plus another 4 bytes so the Array could point to
the string.

And storing the character code as a number wouldn't help much either as
JavaScript would use a 64 bit double precision float for that.

Richard.
Jul 20 '05 #7
Richard Cornford wrote:
"rf" <ma**********@t he.time> wrote in message
news:5u******** ************@ne ws-server.bigpond. net.au...
<snip>
GAK. 10,000 by 20,000. Hmmm lets see, even if this were a
character array that would be <calculates /> a 190+ megabyte
array. Any computer with less than half a gig of memory
would grind to a halt in the paging subsystem.

<snip>

Even that seems an optimistic calculation as JavaScript has no character
data type, and if it did it would be a two byte Unicode character.

I would think that storing a single character would require JavaScript
to use a string value, probably implemented as a minimum of a 32 bit
unsigned integer describing the length plus the string date (2 bytes
minimum for a char), plus another 4 bytes so the Array could point to
the string.

And storing the character code as a number wouldn't help much either as
JavaScript would use a 64 bit double precision float for that.

Richard.


Not to mention that even to the most frugal representation to send the data
to the browser would consist of something like:

var a=[1,2,3,4,5...];

Even for a 10,000 member array consisting of a sequence of numbers (which of
course you wouldn't send to the browser anyway, since you could generate it
locally), you'd be looking at nearly 50,000 bytes of data sent to construct
the array:

9 x 1 digit numbers + 89 x 2 digit numbers + 899 x 3 digit numbers + 8999 x
4 digit numbers + 10000 x comma

If you start looking at sending an array of say, 10,000 5 digit product
codes, you're now looking at over 60K worth of data to download a browser
over an average 3K/s dialup line, so 20 seconds just to finish loading the
page.

Unless you have something really astonishing to sell or say, few people
would wait that long.

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #8
Doesnt make much difference... Is your array in MBs or GBs :) wont be..
so no need to have any worry for large arrays... we have bandwidth these
days... dsl/cable/t1... why should one have speed issues.

Keyur Shah
Verizon Communications
732-423-0745

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #9
In article <3f************ *********@news. frii.net>, keyur shah
<ke***@software klinic.com> writes:
Doesnt make much difference... Is your array in MBs or GBs :) wont be..
so no need to have any worry for large arrays... we have bandwidth these
days... dsl/cable/t1... why should one have speed issues.


Obviously, you are unaware (or choose to ingore) the fact that over half the
Internet still connects via dialup. So it *does* make filesize an issue.

http://www.jibbering.com/faq/#FAQ2_3
With regards to quoting when posting.
--
Randy
Jul 20 '05 #10

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

Similar topics

15
2359
by: cody | last post by:
We have a huge project, the solutuion spans 50 projects growing. Everytime I want to start the project I have to wait nearly over 1 minute for the compiler to complete building. This is unaccaptable. I thought about loading only the project I need into visual studio and not the whole solution. The problem is that the compiler tells me it cannot find the referenced dlls (project references) although they are all lying in their bin and obj...
17
25166
by: Havatcha | last post by:
Does anyone have a benchmark for the processing overhead of the STL Vector class, vs a C style array? I would dearly love to use Vectors, but am paranoid about slowing my real-time code down. Can anyone reassure?
50
6191
by: jacob navia | last post by:
As everybody knows, the C language lacks a way of specifying bounds checked arrays. This situation is intolerable for people that know that errors are easy to do, and putting today's powerful microprocessor to do a few instructions more at each array access will not make any difference what speed is concerned. Not all C applications are real-time apps.
6
2783
by: Dennis | last post by:
I was trying to determine the fastest way to build a byte array from components where the size of the individual components varied depending on the user's input. I tried three classes I built: (1) using redim arrays to add to a normal byte array (2) using an ArrayList and finally (3) using a memorystream. These three classes are listed below the test sub called "TestBuildByteArray". It was interesting that using the memorystream was...
6
2459
by: Michael Gray | last post by:
VS 2003 VB.net Win2000 SP4 The System.Array class seems to be limited to 32 bit addresses, meaning that one can only assign 2^32 elements. Is there any way that I can have an array that allows 2^64 elements? Or doesn't the CLR support this on a 32 bit opsys? I suspect that I am going to have to make such a beastie myself...
8
1702
by: Sullivan WxPyQtKinter | last post by:
a relation database has admiring search efficiency when the database is very big (several thousands or tens of thousands of records). But my current project is based on XML, for its tree-like data structure has much more flexibility; and DOM, which could be manipulated just like a tree. However, how to establish such a XML data base for search when it contains 10,000 records (One record usually contain 10~30 tags) or more? My search...
8
2300
by: luke.yolanda | last post by:
is anyone know how to implement a huge 2-D array? such as ' unsigned char a; ' I compile and run it in VC 6.0, but it show me an error.... thank you guys
19
2459
by: Jim West | last post by:
The execution speed of the following code is dramatically faster if I declare some arrays globally rather than locally. That is FOO a, b, c; void bar() { ... } runs much faster (up to 33%) than
4
1269
by: busnet | last post by:
Hi. I've got the following problem: I have a huge xml-file that represents a street map of a city. Each street is stored as a couple of coordinates (start, end and all the turns). When I set a marker in a google map, I want to find all streets that are near this marker position. I now parse the whole file as a simpleXML object, and calculate the distances to each street segment (using linear algebra algorithms, that is, constructing the...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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
10206
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
10035
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...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
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
6662
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
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.