开发者

measuring method execution time using Unity interception

Do you know a pattern for method execution time measurement using EntLib's Unity and 开发者_如何学运维its interception mechanism?


You can create an ICallHandler (or very similar IInterceptionBehavior in Unity 2.0) implementation like below and add it to your object's execution timeline

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜