我在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