I am using Visual Studio Express Edition and it does not have a profile analyzer or code.
Code with two delegates performing the same task, one using an anonymous method and one using a Lambda expression. I want to compare which one takes less time.
How can I do this in VS express? (not just for delegate for methods)
If this is a duplicate, please connect it.
thanks
I tried Like This:
DateTime startTime = DateTime.Now; returnSqr myDel = x => x * x; Console.WriteLine("By Lambda Expression Square of {0} is: {1}", a,myDel(a)); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; Console.WriteLine("Execution time 1:" + duration.Milliseconds); DateTime startTime2 = DateTime.Now; returnSqr myDel1 = delegate(int x) { return x * x;}; Console.WriteLine("By Anonymous Method Square of {0} is: {1}", a, myDel1(a)); DateTime stopTime2 = DateTime.Now; TimeSpan duration2 = stopTime2 - startTime2; Console.WriteLine("Execution Time 2:" + duration.Milliseconds);
The conclusion gives:
Runtime 1: 0
Runtime 2: 0
Why is that?
source share