简体   繁体   English

WPF:应用程序在Visual Studio调试模式下运行的速度比可执行文件慢得多

[英]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.

相关问题 C#WPF代码在Visual Studio中比从控制台运行得更快,而在另一个文件夹中运行得更慢 - C# WPF code runs faster in Visual Studio than from console, and slower from another folder DynamicMethod 在 Release 模式下比在 Debug 模式下慢 - DynamicMethod is slower in Release mode than Debug mode 即使在调试模式下关闭应用程序,Visual Studio也不会停止 - Visual Studio is not stopping even after closing the app in debug mode WPF Visual Studio 调试 - 控制台 - WPF Visual Studio Debug - Console 当我调试 WPF 项目时,Visual Studio 运行错误的项目/只是空白 - When I Debug my WPF Project Visual Studio runs the wrong Project/Is just blank C#程序在调试模式下运行,但不是直接由可执行文件运行 - C# Program Runs in Debug Mode but not Directly by the Executable Visual Studio - 调试配置文件中指定的调试可执行文件不存在 - Visual Studio - Debug Executable Specified in the Debug Profile does not Exist 在调试模式下运行Visual Studio控制台应用程序的CPU使用率不会超过50% - Running Visual Studio console application in debug mode consumes no more than 50 percent cpu usage XUnit在Visual Studio中的调试模式下声明异常 - XUnit Asserting Exceptions In Debug Mode In Visual Studio 在调试模式下Visual Studio行高亮显示 - Visual Studio line highlight in Debug mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM