Write a program to find the program execution time in c#

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 437
The below program will do so

using System;
using System.Diagnostics;
using System.Linq;

namespace TodayTask
{
class Program
{
static void Main(string[] args)
{
var stopWatch = new Stopwatch();

//start measuring the initial time of the program
stopWatch.Start();

//do some heavy work
Enumerable
.Range(1, 200000)
.ToList()
.ForEach(i => Console.WriteLine(i));

//finally stop the watch
stopWatch.Stop();

//measure the total executuion time
Console.WriteLine(stopWatch.ElapsedTicks);
Console.ReadLine();
}
}
}

Comments or Responses

Login to post response