LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unflatten From XML.vi is slow. O(N^4) slow.

I use the built-in LV routines for reading and writing XML files to store the configuration data for my application.  They work well enough so long as I avoid large arrays.

I accidentally wrote out a 255x255 array of Booleans and the re-read took several minutes on a 2.4 GHz Pentium 4.  I have since re-coded the app so that I don't need to write out that array at all in the configuration.

However, I looked a little closer at the behavior of "Unflatten From XML.vi".  Just be writing out and re-reading in arrays of Booleans, it is evident that this VI has approximately O(N^4) behavior, so run times go as the fourth power of the array.  While the LV XML format for arrays is pretty wordy (something like 32 bytes on top of the string value of each array element), this behavior renders the built-in XML handling useless for all but the most modest data sets.  I know that XML parsing is pretty CPU-intensive but it's not that bad! 

So, for any LV folks reading this, is a replacement or update planned for this VI in future releases?
0 Kudos
Message 1 of 5
(3,375 Views)
bump.
0 Kudos
Message 2 of 5
(3,351 Views)
Hi Brian,

Do you have some VI's and sample xml files that you could zip up and attach to this post so we can quickly test this?

Cheers,
Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 3 of 5
(3,325 Views)
Hi,

Attached is a sample VI that illustrates the issue.  I use the "sum all elements" VI to make sure that the "Unflatten from XML" VI is actually
being run.

The default values are from the test machine, a 2.4 GHz Pentium 4 running Windows XP.  If you run for larger array sizes (and are patient!) you'll get a convergence of the power law fit to a hair over 4.  With this scaling it can take 5-10 minutes to load an array of size 256 or larger.
0 Kudos
Message 4 of 5
(3,297 Views)
Thanks Brian,

I am looking into your VI and I will find out if this is "expected" behavior or not. 😉

Cheers,
Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 5 of 5
(3,268 Views)