StreamReader is extremely slow.

Does anyone else have a better method for this? I’m currently using this code to read through 68,500 lines of text. But it takes well over 2 minutes to. Does anyone else have a more efficient method? My goal is to read all the text and put the numbers into one array and string into another. Also the text is only 1 line, does that affect anything?

void test(){
		System.IO.StreamReader sr = new System.IO.StreamReader(Application.dataPath + "/listofgames.txt");	
		string alltext = sr.ReadLine();
		string[] test = alltext.Split(',');


I do not believe that your reader is necessarily slow, but String.Split()
is pretty performance heavy (You might want to google some things on that). Especially on the memory side of things it’s heavy.
It might be a better idea to divide each word/value/instance (don’t know what you are using it for) by a line break. That would be faster I think. And if you’d like to group some values you can just use specific words to indicate that a new group comes next.
Alternatively you could optimize the amount of data you need to read.
And lastly you could also use a JSON library or .XML file to store your data.

Good luck with your optimization!