专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »XML教程 » msxml6.0分析器:InsideMSXMLPerformance(MSXML性能分析)(4) »正文

msxml6.0分析器:InsideMSXMLPerformance(MSXML性能分析)(4)

来源: 发布时间:星期四, 2009年2月12日 浏览:214次 评论:0


First DOM Walk Working Set Delta prefix = o ns = \"urn:schemas-microsoft-com:office:office\" />

DOM树遍历引起工作空间增量

Walking the DOM tree for the first time has an impact _disibledevent=>在第次遍历DOM树时对工作空间这个度量指标会有影响树中有些节点会被创建为了介绍说明这这里提供了首次遍历载入内存样品数据时工作空间增量:

Sample
样品

Working delta (percentage)
工作空间增量(百分比)

Ado.xml

0

Hamlet.xml

25

Ot.xml

14

Northwind.xml

36

According to these results, it seems that the ADO attribute doesn\'t have any nodes created _disibledevent=>以上结果显示ADO.xml在此时并不需要创建任何节点

createNode Overhead

createNode开销

Creating a DOM tree from scratch results in a higher peak working than loading the same document from disk. To illustrate this, I created a DOM document with 10,000 elements looking like this:

在内存中临时创建个DOM树比从磁盘上载入同样文档会产生更高工作空间峰值为了介绍说明这这里创建了个DOM文档包含10,000个相同如下元素:

<item>this is a test</item>

Then I compared the load time, load plus walk time (to force _disibledevent=>然后比较载入时间载入加遍历时间(强制构造)和直接创建时间下表显示了相关工作空间大小:

Function
功能

Time (milliseconds)
时间(单位为毫秒)

Working (s)
工作空间(单位为字节)

Load

146

842,137

Load+Walk

148

1,173,914

Create

740

2,503,066

These results show that loading a document is roughly five times faster than creating the same document from scratch in memory. The reason is that the process of creating a document requires a lot of DOM calls, which slows things down. Merely loading the document bypasses all this and goes directly to the ernal data structures.

以上结果显示载入个文档比在内存中直接创建同样文档要快差不多5倍原因是创建文档时需要有多次DOM执行就会变慢而载入文档就避开了这些可以直接进入内部数据结构了



Walk vs. selectSingleNode

遍历和selectSingleNode

The fastest way to walk the tree is to avoid the children collection and any kind of .gif' /> access. Instead, use firstChild and nextSibling:

最快遍历树思路方法是避免子集合和任何访问取而代的使用firstChildnextSibling:

function WalkNodes(node)

{

var child = node.firstChild;

while (child != null)

{

WalkNodes(child);

child = child.nextSibling;

}

}

The following table shows the results for the sample test files—walking all elements, attributes, and text nodes:

以下表格显示了样本文件遍历元素、属性和文本节点测试结果:

Sample
样本

Walk time (milliseconds)
遍历时间(毫秒)

Number of nodes
节点数量

Nodes/second
节点/

Ado.xml

243

63,723

262,234

Hamlet.xml

63

12,100

192,063

Ot.xml

660

118,720

179,878

Northwind.xml

33

6,438

195,090



[1][2]下

0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: