22-degrees
Well-known member
Hi all,
I have data being exported to .txt/.csv files every 2 seconds.
Output at max expected load is c200Mb per hour.
I initially started exporting to individual sector files but when I checked on the output after a few hours, 80+ files being written to, 3 lines at a time using Filesystem.WriteAllText was taking almost 10 seconds..
I did a little research and decided to try StreamWriter in a 'Using' block and lump all the data into one file.. Hey Presto, almost 100 times faster according to stopwatch data..
However I have noticed a number of before and after differences.. Before, when 80+ files were being written to, the CPU and RAM gauge were low, but my PC was sluggish.. Now, with StreamWriter to one file, my CPU and RAM gauge are a lot higher, but PC seems to be responding a lot quicker than before to general operation.
My question is, what is the best or most efficient way to manage larger txt files such as 100Mb+ in vb.net? I am not 100% clear on how exactly 'Stream' manages the file and I am not a regular user of the "Using" block either. This is my first time exporting such a large amount of data so CPU/RAM efficiency has never been a concern of mine..
Hoping someone can point me in the right direction.
I have data being exported to .txt/.csv files every 2 seconds.
Output at max expected load is c200Mb per hour.
I initially started exporting to individual sector files but when I checked on the output after a few hours, 80+ files being written to, 3 lines at a time using Filesystem.WriteAllText was taking almost 10 seconds..
I did a little research and decided to try StreamWriter in a 'Using' block and lump all the data into one file.. Hey Presto, almost 100 times faster according to stopwatch data..
However I have noticed a number of before and after differences.. Before, when 80+ files were being written to, the CPU and RAM gauge were low, but my PC was sluggish.. Now, with StreamWriter to one file, my CPU and RAM gauge are a lot higher, but PC seems to be responding a lot quicker than before to general operation.
My question is, what is the best or most efficient way to manage larger txt files such as 100Mb+ in vb.net? I am not 100% clear on how exactly 'Stream' manages the file and I am not a regular user of the "Using" block either. This is my first time exporting such a large amount of data so CPU/RAM efficiency has never been a concern of mine..
Hoping someone can point me in the right direction.