Click to See Complete Forum and Search --> : Help with optimization


Marraco
May 28th, 2008, 12:31 PM
This line: LíneasDeArchivo = Split(sr.ReadToEnd(), vbCrLf) in this code:
Dim LíneasDeArchivo() as String
fs = File.OpenRead(FilePath)
sr = New StreamReader(fs)
LíneasDeArchivo = Split(sr.ReadToEnd(), vbCrLf)
fs.Close()
takes too much time (63 seconds, because there are 2,000,000.0 lines to pass to LíneasDeArchivo() array).
¿somebody knows a faster way?
_

Shuja Ali
May 28th, 2008, 01:09 PM
You could as well read one line at a time instead of reading the whole file. Imagine, what happens if the file is greater than 2 GB. I would never read the whole content of file unless I am 100% sure that the file is going to be small.

TheCPUWizard
May 28th, 2008, 01:15 PM
Also if the lines are independant, you can process each one using a worker thread....