测个效率(插入100000个数据
dictionary:- a=timer
- set d=createobject("scripting.dictionary")
- for i=0 to 100000
- d.add i,0
- next
- b=d.keys()
- msgbox timer-a
复制代码 0.13
原生动态数组:- a=timer
- dim d()
- redim d(-1)
- for i=0 to 100000
- redim preserve d(i)
- d(i)=0
- next
- b=ubound(d)
- msgbox timer-a
复制代码 0.13(和上面的几乎一致
原生普通数组:- a=timer
- dim d(100000)
- for i=0 to 100000
- d(i)=0
- next
- msgbox timer-a
复制代码 0.007
js数组:- c=timer
- set html=createobject("htmlfile")
- Set window = html.parentWindow
- window.execScript "var j=new Array()"
- set a=window.j
- for i=0 to 100000
- a.push 0
- next
- msgbox timer-c
复制代码 0.14(转换为vbs数组需要用到new vbarray 时间会再长一点
wia vector:- c=timer
- set v=createobject("wia.vector")
- for i=0 to 100000
- v.add 0
- next
- msgbox timer-c
复制代码 0.51
.net arraylist:- c=timer
- Set a = CreateObject("System.Collections.ArrayList")
- for i=0 to 100000
- a.add 0
- next
- msgbox timer-c
复制代码 0.4
当然 各有千秋 比如arraylist里的一大堆方法 原生的速度 vector的byte() js数组同时可以作为栈 队列等等 |