0

I have a very strange problem. I am using a WPF application to retrieve image frames from a device. The communication with the device is done by calling the c++ dll

like this

       [DllImport(DLL_FILE_PATH, CallingConvention = CallingConvention.Cdecl)]
    public static extern uint Acquisition_Init();

When I run a build from Visual Studio 2022 (Release or Debug) - the application runs and frames coming at 45 FPS.

But when I run just builded .exe file from Release folder - FPS reaches max 30 FPS. What could be the reason for this strange behavior?

Since when does a program run through Visual Studio work faster and better than a simple Release version?

  • That is indeed strange. But it's difficult to guess on something with the information you give. I'm not sure on where to start, though. Maybe you need to instrument your code and measure (inside the program) which operation takes longer. Have you had a look at the overall CPU usage of your application (both ways)? – PMF Aug 01 '22 at 12:26
  • I would recommend running your application in a performance profiler to see what it spends time in. I would probably also recommend avoiding external dependencies when benchmarking, i.e. If you want to measure the time to process images, setup a test that *only* does that, and does not also capture images from any device. – JonasH Aug 01 '22 at 14:26
  • @JonasH Update!!!- If i run the exe file and in Visual Studio Debug attach this process - again I get 45 FPS !!! What happens to the process when it is in Visual Studio or attached to debug? – Евгений Федоров Aug 01 '22 at 15:06
  • Attaching the debugger may affect performance, since some optimizations will be disabled. But I would not expect such a large change, and that the performance should be *lower* with the debugger attached. While it is not impossible that optimizations actually reduce performance, I suspect that something weird is going on. So you should try to isolate the code that is causing this issue, i.e. test parts in isolation until you can find the culprit. – JonasH Aug 01 '22 at 15:11
  • Solution was here https://stackoverflow.com/questions/16612236/why-is-my-c-sharp-program-faster-in-a-profiler/38404066#38404066 – Евгений Федоров Aug 02 '22 at 11:06
  • Does this answer your question? [Why is my C# program faster in a profiler?](https://stackoverflow.com/questions/16612236/why-is-my-c-sharp-program-faster-in-a-profiler) – Jiale Xue - MSFT Aug 03 '22 at 01:13
  • @JialeXue-MSFT Yes - I posted comment above – Евгений Федоров Aug 03 '22 at 06:31

0 Answers0