我在Windows 8.1 x64上使用C#.NET 4.0应用程序需要很长时间(18秒)来执行某些操作。我想尝试诊断为什么会发生这种情况。过程监视器跟踪显示:当程序响应缓慢时,该程序在做什么?
╔═══════════════╦════════════════════════════════════════╗
║ Relative Time ║ Operation ║
╠═══════════════╬════════════════════════════════════════╣
║ 00:02.000000 ║ Thread Create ║
║ 00:02.000100 ║ Thread Create ║
║ 00:04.000000 ║ Thread Create ║
║ 00:04.000100 ║ Thread Create ║
║ 00:04.000200 ║ Thread Create ║
║ 00:04.000300 ║ Thread Exit ║
║ 00:04.000400 ║ Thread Create ║
║ 00:04.000500 ║ TCP Disconnect ║
║ 00:04.000600 ║ Thread Exit ║
║ 00:06.000000 ║ Thread Create ║
║ 00:06.000100 ║ Thread Create ║
║ 00:06.000200 ║ Thread Create ║
║ 00:06.000300 ║ Thread Create ║
║ 00:06.000400 ║ Thread Create ║
║ 00:07.000000 ║ Thread Exit ║
║ 00:10.000000 ║ Thread Create ║
║ 00:11.500000 ║ CreateFile ║
║ ║ // read the file contents ║
║ 00:11.540000 ║ CloseFile ║
║ 00:11.541000 ║ CreateFile ║
║ ║ // read the file contents ║
║ 00:11.600000 ║ CloseFile ║
║ 00:12.100000 ║ Thread Exit ║
║ 00:19.000000 ║ Thread Exit ║
║ 00:20.000000 ║ Thread Exit ║
║ ║ // from here on things respond quickly ║
╚═══════════════╩════════════════════════════════════════╝
有几个大的差距,我想更好地了解该程序正在做什么。假设我可以得到符号(但可能不是源),有什么我可以做的,以更好地了解发生了什么?我愿意使用WinDbg或Windows性能监视器。我只想从哪些工具开始,找到一些方向来缩小这些差距。
Visual Studio 2015在整个应用程序生命周期中都有一些非常棒的性能工具。它也在您调试时会告诉您线到线的执行速度。现在CTP是免费下载的。 – Greg 2015-02-06 17:44:48