From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange 'Read from XML' performance issues

I was recently benchmarking the "Read From XML" VI to troubleshoot a performance problem I am having, and I have found some really odd behavior. 

 

If I generate a large array of clusters, using the code below, the performance is quite acceptable. "Read From XML" takes around 70 ms to process a 4900 element array:

Example1.png

 

Here are charts of the execution time versus array size, and character count versus array size: 

 

Results1.pngStringSize1.png

 

The performance of "Read From XML" drops by orders of magnitude if I encapsulate the array of clusters inside another cluster, like shown:

Example2.png

 

The execution time versus the number of elements, and the string length are below:

 

Results2.pngStringSize2.png

 

So while the string length is essentially identical between the two files, the execution time is 70 times slower, taking almost 5 seconds to process a 4900 element array, when a cluster encapsulates the array. "Unflatten from XML," "Flatten To XML," and "Write XML" all perform well in both cases. 

 

Is there any explanation for this performance hiccup, or tricks to circumvent it?

 

0 Kudos
Message 1 of 4
(3,001 Views)

This is expected. A xml document has a tree structure, if you add a nested level the time to navigate the whole tree structure will increase exponentially.

 

Ben64

0 Kudos
Message 2 of 4
(2,942 Views)

Read from XML isn't supposed to be navigating the entire tree structure though, AFAIK. It just returns the string contents of <LVData> with the <version> tag removed. It shouldnt need to look any deeper than top level tags. Unflatten from XML, which then processes the document, scales just fine in both cases. 

0 Kudos
Message 3 of 4
(2,931 Views)

@ngarneski wrote:

Read from XML isn't supposed to be navigating the entire tree structure though, AFAIK. It just returns the string contents of <LVData> with the <version> tag removed. It shouldnt need to look any deeper than top level tags. Unflatten from XML, which then processes the document, scales just fine in both cases. 


Open the block diagram of Read From XML File(string) and look at the vi called ParseXMLFragments.vi, this vi navigates the whole tree structure.

 

Ben64

0 Kudos
Message 4 of 4
(2,921 Views)