09-04-2018 09:36 AM
I have a program that extracts information from multiple log files in a folder (Folder-Value change event). This sub-program is slow taking more than 10 seconds at its bottleneck ""read from text file" function, and afterwards, it seems Labview finds an optimized technique and it subsequently takes under a second. I can't tell why the "read from text file" is slow at first and this seems to be the problem independent of the larger code, it reads quite slowly (20ms/file; 700files = 14 secs) the first time in the attached code (for different folders) and optimizes afterwards if still in memory. To see it run slowly again may require restarting your PC and running the program.
I can't figure out why and how to prevent the slow performance. I have programmed it in multiple ways - the options are in the Diagram disable structure, it still behaves that way.
09-04-2018 09:52 AM
Your timing loop is coded incorrectly. That would explain the variable time reported.
Put the file-string through the first flat-sequence structure. That will make your timing more reliable.
09-04-2018 10:34 AM
I am observing the time it takes for each file to go through the loop, it takes between 10-30ms per file the first time and 0 afterwards.
Either ways, its just generally much slower to read text from file in the loop
09-04-2018 05:00 PM
I have ran your code and a cleaned up version and all files take the same 0 to 1 ms time. I am using LV2016, but I doubt that would make a difference.
Have you looked at the first file in Notepad++. It might be corrupted.
09-04-2018 05:59 PM
Thanks, the files are not corrupted. It runs well after the first try on any folder containing text files right after booting PC, and I ran program on different PCs
09-05-2018 01:17 AM
How big is this file? Could it be that the first time it is slow because it is read directly from the disk and subsequently read from the file cache instead?
09-05-2018 01:10 PM
The files are usually between 5MB - 50MB. But as seen in the vi, I only extract the first KB out of the file.
That is what I assumed myself, but there are still some instances I re-boot my PC and run the vi and it runs under a second.