巨大的阵列 - 速度问题? [英] Huge arrays - speed problems?

查看:57
本文介绍了巨大的阵列 - 速度问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javascript中是否有任何速度问题,因为有非常大的
阵列?我知道如果阵列变得足够大,带宽和下载时间可能是一个问题,但是需要花费大量时间才能获得一个非常大的阵列吗? br $> b $ b -

-

Fabian

经常长时间访问我的网站!
< a rel =nofollowhref =http://www.lajzar.co.uktarget =_ blank> http://www.lajzar.co.uk

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

推荐答案

Fabian hu kiteb:
Fabian hu kiteb:
javascript中是否有任何速度问题,而且数组真的很大?我知道如果阵列变得足够大,带宽和下载时间可能是一个问题,但是否需要花费大量时间来访问一个非常大的阵列?
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?




具体来说,是处理器/磁​​盘访问时间的inordiante。

-

-

Fabian
经常访问我的网站很长一段时间!
http:// www.lajzar.co.uk



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


Fabian说:

有没有速度问题在javascript中有非常大的数组?我知道如果阵列变得足够大,带宽和下载时间可能是一个问题,但是否需要花费大量时间来访问一个非常大的阵列?

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?




这取决于你认为的真的很大。


我写了一个简单的脚本来创建一个给定大小的数组,
遍历数组设置每个元素等于1,

<注意这需要多长时间>

然后遍历数组,将所有数据相加那些1',和

<注意这需要多长时间>


我在Netscape 7.1和IE 6中运行了这个,带有大小的数组

10,000,10,000和1,000,000个元素,记录时间

,以秒为单位初始化数组,然后访问每个

元素(总计它们) )。所有的时间都接近零

,除了100万元素。这花了Netscape 3秒

初始化和2秒访问,IE 20秒(!)

初始化,但也有2秒访问所有元素。


这是一个相对较慢的处理器。



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.


Lee hu kiteb:
Lee hu kiteb:
Fabian说:

javascript中是否有任何速度问题,而且数组真的很大?我知道如果阵列变得足够大,带宽和下载时间可能是一个问题,但是否需要花费大量时间来访问一个非常大的阵列?

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?


<这取决于你认为是什么非常大。

我写了一个简单的脚本,创建一个给定大小的数组,
循环遍历数组设置每个元素等于1,
<注意这已经花了多长时间>
然后循环通过数组,将所有这些1'加起来,并且
<注意这需要多长时间>

我在Netscape 7.1和IE 6中运行了这个,大小为10,000,100,000和1,000,000个元素的数组,记录时间(以秒为单位)初始化数组,然后到访问每个
元素(总计)。除了100万个元素外,所有时间都接近于零。这需要Netscape 3秒初始化和2秒访问,IE 20秒(!)
初始化,但也可以2秒访问所有元素。



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.



我想象的最大阵列大小将是10,000,即
20,000。我原本设想单个字符文本,但没有

功能性原因他们不可能是nunbers,并且数字可能在js中更好地工作

无论如何。很高兴知道我不太可能达到任何速度

障碍。

-

-

Fabian

经常长时间访问我的网站!
http ://www.lajzar.co.uk



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


这篇关于巨大的阵列 - 速度问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆