简体   繁体   中英

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.

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.

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.

Applications that run in debug mode in visual studio experience a lot of overhead with communicating with VS's debugger. 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. The ones started from the filesystem would run faster and even overtake the one started in VS debug mode.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM