[英]WPF: App runs much slower in Visual Studio Debug Mode than executable
I'm helping fix performance issues with an old WPF application and one of the main issues that we encounter is that the app runs much slower if started in Debug Mode from Visual Studio, as compared to running the app directly from the /bin folder. 我正在帮助解决旧的WPF应用程序的性能问题,我们遇到的主要问题之一是,与直接从/ bin文件夹运行应用程序相比,如果从Visual Studio以调试模式启动该应用程序,运行速度要慢得多。
Comparison: 比较:
+------------+------+
| Run Mode | Time |
+------------+------+
| Debug Mode | 106s |
| Executable | 17s |
+------------+------+
As my WPF knowledge is very basic, and it's not an app I've been working on, I haven't got a clue what to look for. 由于我的WPF知识非常基础,并且不是我一直在从事的应用程序,因此我不知道该寻找什么。
Any suggestions on what may cause this difference? 关于什么可能导致这种差异的任何建议?
PS: Start without Debugging (Ctrl+F5) runs as fast as the executable, so it seems Debug Mode overhead. PS:无需调试即可启动(Ctrl + F5),其运行速度与可执行文件一样快,因此似乎在调试模式下开销很大。
Applications that run in debug mode in visual studio experience a lot of overhead with communicating with VS's debugger. 在Visual Studio中以调试模式运行的应用程序在与VS的调试器进行通信时会遇到很多开销。 Their output, state, and event are logged which reduces the speed.
记录其输出,状态和事件,这会降低速度。
I experienced this a while back when running experiments in evolutionary computing. 我在进行进化计算实验时曾经历过一段时间。 I'd start the console app from visual studio first, create new instances by starting directly from the file system.
我先从Visual Studio启动控制台应用程序,然后直接从文件系统启动来创建新实例。 The ones started from the filesystem would run faster and even overtake the one started in VS debug mode.
从文件系统启动的文件将运行得更快,甚至超过在VS调试模式下启动的文件。
Try to be cool with it. 尝试保持冷静。 Debug mode is always slower.
调试模式总是较慢。 If what you want is speed, i'd suggest building the project, then starting it directly from the file system.
如果您想要的是速度,我建议您构建项目,然后直接从文件系统启动它。
The reason for this difference is all code optimizations are turned off by default in debug mode . 产生这种差异的原因是,默认情况下,所有代码优化在调试模式下均处于关闭状态 。 This is because it is easier to debug when the binary code is direct correspondence to the source code.
这是因为,当二进制代码与源代码直接对应时,调试起来更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.