-1

I developed a console application which takes the ipaddress as input and provides the uptime of the devices in the log file. Totally 27000 ipaddress are there. it takes nearly 2 days to give the output.

Please help how can i make speed my application using multi therading.

jinnah
  • 1
  • 2
  • You will not be able to read all those lines anyway so I would suggest saving to file. Console output is pretty slow – Michał Apr 06 '14 at 10:00
  • 1
    Also, try this: http://stackoverflow.com/questions/5272177/console-writeline-slow – Michał Apr 06 '14 at 10:01

1 Answers1

0
public static class Program
{
    internal static string Result(string ip)
    {
       // your function here
    }

    internal static void Main()
    {
        const int ParallelJobs = 100;

        var ips = File.ReadAllLines("your.data");

        var results = ips.AsParallel().WithDegreeOfParallelism(ParallelJobs ).Select(Result).ToList();

        File.WriteAllLines("your.results", results);
    }
}

Basically, that's it. Now it runs in parallel. Your jobs seem to be I/O bound with a lot of idle waiting time, so I would set the degree of parallelism quite high. "Waiting" can be done in huge batches :)

nvoigt
  • 68,786
  • 25
  • 88
  • 134