2012-01-18 54 views

回答

1

使用事件探查器来做到这一点,例如Visual Studio内置的一个。 您可以从分析菜单中找到它。它会显示你的代码中所有方法的时间和发生次数。

当然也有第三方的解决方案,例如Ants Profiler

3

排序的。您可以使用选项-stats slowmethods找到最慢的方法(也可以使用-statsOnly来简化日志输出)。

遗憾的是,输出结果如下:

Methods taking the longest: 
1: Method #196, 00:00:08.1438107 
2: Method #143, 00:00:07.1916795 
3: Method #68, 00:00:02.2282228 
4: Method #71, 00:00:01.4211421 
5: Method #438, 00:00:01.3781378 
6: Method #452, 00:00:00.8640864 
7: Method #78, 00:00:00.8330833 
8: Method #439, 00:00:00.7390739 
9: Method #72, 00:00:00.5760576 
10: Method #75, 00:00:00.4090409 

我不知道是否有以找到方法号方法名称的方式。

+0

呵呵,那还是很有用的,谢谢! +1 – Mehrdad 2012-01-19 04:14:50