hey all

The objective is to read a massive textfile (200+mb)
each line is a "entry"
then output the totals of each entry

rob
rob
rhaps
tim

output

rob =2
rhaps =1
tim =1



the code i came up with is here

c# Code:
  1. System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
  2.             Dictionary<String,int> Count = new Dictionary<string,int>();
  3.             string path = @"C:\Documents and Settings\Rob\Desktop\test.txt";
  4.             int num = 0;
  5.             sw.Reset();
  6.             sw.Start();
  7.             using (StreamReader sr = new StreamReader(path))
  8.             {
  9.  
  10.                 string line;
  11.                 while ((line = sr.ReadLine()) != null)
  12.                 {
  13.                     if (Count.ContainsKey(line))
  14.                     {
  15.                         Count[line]++;
  16.                     }
  17.                     else
  18.                     {
  19.                         Count.Add(line, 0);
  20.                     }
  21.                     num++;
  22.                 }
  23.             }
  24.            
  25.             foreach (KeyValuePair<string, int> kvp in Count)
  26.             {
  27.                 Console.WriteLine(kvp.Key+": "+kvp.Value.ToString());
  28.             }
  29.             sw.Stop();
  30.             long time = sw.ElapsedMilliseconds;
  31.             Console.WriteLine("Time = " + time + " milliseconds.");
  32.             Console.WriteLine("Total Rows: " + num.ToString());
  33.             Console.WriteLine("lines per ms: "+ (num / time).ToString());



I was thinking of somesort of parrellel while but im not sure how to do that or if it even exists and if it did exist would it work with the stream reader


the other idea was to load it as a DB and then run a sql command to get the count or something but im not sure if that would be faster or not?


any ideas are greatly appreshated
thanks