i need to calculte the time taken to execute each thread.. so i used this code to do it.
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds,ts.Milliseconds);
Console.WriteLine(elapsedTime, "RunTime");
now my each thread execute a method work(), this is how it goes
void work(){
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
//codes,,,
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds,ts.Milliseconds);
Console.WriteLine(elapsedTime, "RunTime");
}
so now my question is do i need to create an array of 1000 stopwatch objects... or not... because say 1000 work() methods are running concurrently