If you just want to calculate the time elapsed by a process, then why are you using Environment when you're having a
Stopwatch
in the .NET Framework?
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch(v=vs.110).aspx[
^]
You can use the above class, to measure the time elapsed using .NET Framework.
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
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 / 10);
Console.WriteLine("RunTime " + elapsedTime);
}
}
Above code was captured from the link provided.
Using the above code, you can easily set the time and determine the time that had elapsed for that algorithm in your program.