【发布时间】:2016-03-09 12:53:37
【问题描述】:
我正在使用 PostSharp 记录某些方法的性能和其他统计信息。我被要求测量一些子任务的性能和花费的时间,例如调用外部 Web 服务或大型数据库等。
例如,我有一个应用了 AoPLoggingAttribute 的方法。 AoPLoggingAttribute 继承自 OnMethodBoundaryAspect,因此它支持所有已知方法(OnEntry、OnExit、OnSuccess 等)
[AoPLogging]
public MyClass[] MyMainMethod(string myid)
{
//Some code here
LongExecutingTask();
//Rest of the code here
}
测量 LongExecutingTask 所用时间的最佳方法是什么?我不在乎它是否是总执行时间的一部分,但不知何故我需要知道从这个任务中花费的时间。
【问题讨论】:
标签: performance statistics postsharp stopwatch