Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static long Measure(Action action)
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- action();
- return sw.ElapsedMilliseconds;
- }
- var duration = Measure(() => MyMethod(param1));
- TimerInterceptor : IInterceptor
- {
- public void Intercept(IInvocation invocation)
- {
- Stopwatch watch = new Stopwatch();
- watch.Start();
- invocation.Proceed();
- watch.Stop();
- //here you have the value which could be used to log (which I assume you want)
- }
- }
- new ProxyGenerator().CreateInterfaceProxyWithTarget<IMyInterface>(implementedObject, new TimerInterceptor());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement