[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 1# 老刘1号


    但,用vbs写个动态数组类也不难啊?尤其是栈,反倒最简单,倒是队列最麻烦

TOP

回复 3# 老刘1号

谁用vbs处理大量数据啊🤔

TOP

测个效率(插入100000个数据
dictionary:
  1. a=timer
  2. set d=createobject("scripting.dictionary")
  3. for i=0 to 100000
  4. d.add i,0
  5. next
  6. b=d.keys()
  7. msgbox timer-a
复制代码
0.13
原生动态数组:
  1. a=timer
  2. dim d()
  3. redim d(-1)
  4. for i=0 to 100000
  5. redim preserve d(i)
  6. d(i)=0
  7. next
  8. b=ubound(d)
  9. msgbox timer-a
复制代码
0.13(和上面的几乎一致
原生普通数组:
  1. a=timer
  2. dim d(100000)
  3. for i=0 to 100000
  4. d(i)=0
  5. next
  6. msgbox timer-a
复制代码
0.007
js数组:
  1. c=timer
  2. set html=createobject("htmlfile")
  3. Set window = html.parentWindow
  4. window.execScript "var j=new Array()"
  5. set a=window.j
  6. for i=0 to 100000
  7. a.push 0
  8. next
  9. msgbox timer-c
复制代码
0.14(转换为vbs数组需要用到new vbarray 时间会再长一点
wia vector:
  1. c=timer
  2. set v=createobject("wia.vector")
  3. for i=0 to 100000
  4. v.add 0
  5. next
  6. msgbox timer-c
复制代码
0.51
.net arraylist:
  1. c=timer
  2. Set a = CreateObject("System.Collections.ArrayList")
  3. for i=0 to 100000
  4. a.add 0
  5. next
  6. msgbox timer-c
复制代码
0.4

当然 各有千秋 比如arraylist里的一大堆方法 原生的速度 vector的byte() js数组同时可以作为栈 队列等等

TOP

回复 7# 老刘1号


    嗯 为啥选这么个较小的数 是因为如果加个0dictionary会卡着不动就很怪

一般来说用动态数组都会像你这么说地“惰性” 比如要遍历文件夹啥的

之前老是听说dictionary要比动态数组慢 这么看似乎还要快些?

TOP

返回列表