【问题标题】:measuring method execution time using Unity interception使用 Unity 拦截测量方法执行时间
【发布时间】:2010-06-23 12:03:16
【问题描述】:

您知道使用 EntLib 的 Unity 及其拦截机制测量方法执行时间的模式吗?

【问题讨论】:

    标签: profiling unity-container aop


    【解决方案1】:

    您可以像下面这样创建ICallHandler(或在Unity 2.0 中非常相似的IInterceptionBehavior)实现并将其添加到对象的执行时间线中

    public class MeasurementHandler : ICallHandler
    {
      public IMethodReturn Invoke(IMethodInvocation input,
                                   GetNextHandlerDelegate getNext)
      {
        StartTimer(); // implement it :)
        IMethodReturn msg = getNext()(input, getNext);  
        StopTimer(); // implement it :)
        return msg;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-14
      • 2012-08-29
      • 2015-09-14
      • 2012-09-08
      • 2023-04-07
      相关资源
      最近更新 更多