vc3/Afterthought — Issue #27: Measuring execution time of a method, again
Author: ogreboy
Created: 2011-10-24 05:03:06+00:00
State: open

Just read issue #16 on measuring execution time of a method and looked at the unit test.

What I am trying to do, similar to logging, is decorate the class with a PerformanceAttribute and exclude methods or constructors
with with a DisablePerformanceAttribute.

In #16 you give the code sample:

method.Context()
.Before((T instance, string methodName, object[] parameters)
=> { var s = new Stopwatch(); s.Start(); return s; })
.After((T instance, string methodName, Stopwatch stopwatch, object[] parameters)
=> instance.Result = (int)stopwatch.ElapsedMilliseconds);

This is does not work for me when I use, similar to the LoggingAmender:

Methods
.Where(m => ShouldAmend(m.MethodInfo))
.Before((T instance, string method, object[] parameters) => { var s = new Stopwatch(); s.Start(); return s; })
...
;

If this is not the correct approach then what would be, I am not looking to Performance Log not one or two named methods but all methods/constructors in a class.

Really lost.

thanks in advance ...