C# Programming
10-07-2011, 11:00 AM
Hi guys,
I was looking around for a way to measure the time consumption of a certain algorithm in C#.
Here is what I came up with:
public static TimeSpan MeasureTime(Action action) { var startTime = DateTime.Now; action(); var stopTime = DateTime.Now; return stopTime - startTime; } I am wondering if there is a better code to do the job.
Best regards,
Omar Rwemi.
I was looking around for a way to measure the time consumption of a certain algorithm in C#.
Here is what I came up with:
public static TimeSpan MeasureTime(Action action) { var startTime = DateTime.Now; action(); var stopTime = DateTime.Now; return stopTime - startTime; } I am wondering if there is a better code to do the job.
Best regards,
Omar Rwemi.