First Dom Walk Working Set Delta
Workspace increment caused by the first DOM tree travers
Walking the DOM tree for the first time has an impact on the working set metric because some nodes in the tree are created on demand. To illustrate this, I'll show the working set deltas resulting from the first walk over the freshly loaded sample data :
When the DOM tree is traversed for the first time, this metrics will have a certain impact because some nodes in the tree are created. To illustrate this, this is provided for the increment of the working space when the sample data loaded into the memory is provided:
Sample sample
Working Set Delta (Percentage) Workspace Increase (%)
ADO.XML
0
Hamlet.xml
25
Ot.xml
14
Northwind.xml
36
According to these Results, It See the The ADO Attribute Case Doesn't Have Any Nodes Created on Demand.
The above results show that Ado.xml does not need to create any nodes at this time.
Createnode overhead
Createnode overhead
Creatings in a Higher Peak Working Set Than Loading The Same Document from Disk. To Illustrate this, i created a dan information with 10,000 elements loops Like this:
Temporary Creating a DOM tree in memory can generate a higher work space peak than load the same document from the disk. To illustrate this, a DOM document is created here, which contains 10,000 identical elements:
THEN i Compared The Load Time, Load Plus Walk Time (To Force On-Demand Construction), and Create Time, Showing Associated Working Sets.
Then, compare the load time, load the additional calendar (forced construction) and the direct creation time, the following table shows the relevant workspace size:
Function function
Time (MilliseConds) time (in milliseconds)
Working set (Bytes) Workspace (unit is byte)
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 The above and goes Directly to the Internal Data Structures. The above results show that the load is almost 5 times faster than the same document that is directly created in memory. The reason is that when you create a document, you need to have multiple DOM calls, and the execution will slow down. Loading documents avoids this, you can directly enter the internal data structure.
Walk vs. Selectsinglenode
Traversal with Selectsinglenode
THE FASTEST WAY TO WALK The Tree Is To Avoid The Children Collection and Any Kind of Array Access. INSTEAD: Uses User
The fastest way to pass the tree is to avoid subset and any array access. Reverediently, using firstchild and nextsibling:
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:
The following table shows the test results of the sample file traversal elements, attributes, and text nodes:
Sample sample
Walk Time (MilliseConds) Traverse Time (ms)
Number of Nodes Number Number
Nodes / Second Node / 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
However, if you are looking for something in the tree, a much faster way to find it is to XPath via use the selectSingleNode or selectNodes methods. For example, I entered an XPath expression "// willnotfindanything", which walked the entire tree and Got The Following Results That Show The Percentage Improvement over a brute force Tree Walk:
However, if you want to find something in the tree, the faster method is to use XPath with XPath with the Selectsinglenode or SelectNodes method. For example, enter an XPath expression "// willnotnetFindAnything" to find out the result of the result of the improvement of the traversal of the same mandatory tree:
File file Selectsinglenode (Milliseconds) Selectsinglenode (ms)
Improvement (Percentage) improvement (%)
Nodes / Second Node / Second
ADO.XML
173
29
368, 341
Hamlet.xml
11
82
1,100,000
Ot.xml
113
82
1,050,619
Northwind.xml
5
84
1,287,600
Selectsinglenode Is Faster Because It Avoids The Overhead of Calling THROUGH THE COM LYER. INSTEAD AND NEXTSIBLING, IT WORKS BY SINGLE CALL.
SelectSinglenode is faster because it avoids total overhead through the COM layer. It doesn't have to call Firstchild and NextSibling thousands of times, you can only need to call once.
Now, this comparison is really not equal: On one hand, selectSingleNode was doing less walking, because it did not need to look at the text nodes-it could just skip right over them On the other hand, selectSingleNode was doing more work. , because it was comparing each nodeName with the name specified in the query. But you get the idea. in general, selectSingleNode reduces the amount of DOM code you need to write and gives you a noticeable performance improvement.
This comparison is inappropriate: on the one hand, Selectsinglenode traverses less overhead, because it does not need to view text bytes, just skip them. On the other hand, SelectSinglenode has done more work because it is to compare the names specified in the query with each NodeName. But you should have given some points. In general, selectsinglenode reduces the DOM code you want to write, which can bring significant performance improvement.