LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

raed lines from text file execution speed is unreasonable

hello all,
I need to read  text file (1.4M), and scan all the file line and get some info (string,number ect..) from the line.
the program doing that but  the execution speed is unreasonable is take abut 30sec to do that while in VB.net it's take only
1~2sec???? can some one help me!!!!!
i'm using Labview 7.0;
 
here is my code:
 
0 Kudos
Message 1 of 2
(2,189 Views)
Here are some things that will give you dramatic speed improvements.
  1. Do not read the entire file all at once.  Reading 1.4MBytes at once is a slow operation.  It is far faster to read the file in 65,000 character chunks.  You can process it in chunks as well, which brings us to the next point.
  2. The function you use to find a line has to scan the entire input string every time you use it to find the line you need.  Since you are processing the lines sequentially, you can easily go through your data sequentially using something like the match pattern VI to split the string into a line and whatever is left.  I would strongly advise you to look at how the Read LabVIEW Measurement File express VI handles string input.  You can probably copy large chunks of this code, since it is doing almost exactly what you are doing (reading in a file and parsing it line by line).
  3. Your command detection scheme is very inefficient.  Get rid of the inner FOR loop.  Instead, take the two character command you are extracting from the string and use it as the input to a case structure.  The cases of the case structure then become your commands (make sure to include a default for unknown or corrupt commands).  This will reduce your number of compares from 21 per line to 1 per line.
Let us know if you need more help.  There are more ways to attack this problem than the ones I listed, but they should get you there.
0 Kudos
Message 2 of 2
(2,167 Views)