Very slow code run on Linux

29 views (last 30 days)
Mohamed AKI Ahmed
Mohamed AKI Ahmed on 3 Nov 2023
Answered: Udit06 on 21 Nov 2023
Hello. I have a large code that I compiled. The code takes around 2 seconds to run on Windows but when running on Linux, it takes over 500 seconds. The code is not too complex by itself, it basically takes some arguments and do some calculations for them (no plots or anything, just a numeric result). I compiled the code on Linux and tried both MCR and MATLAB on the machine but nothing seemed to have the process faster. I'm wondering what could be the solution to this problem as I need to be running the code on Linux for later production. I'm using MATLAB 2021b

Answers (1)

Udit06
Udit06 on 21 Nov 2023
I understand that your MATLAB program is taking a large amount of time to run in Linux as compared to Windows. As you mentioned that you code is large, to understand which part of the code is consuming the most time, I would recommend you to do code profiling. You can refer to the following MathWorks documentation to understand more about code profiling.
After doing the profiling, you can now pinpoint the bottlenecks that are causing the slowdown. If after profiling you find out that, the slowdown is related to reading a video, you can refer to the following MATLAB answer which deals with a similar issue. Please note this is just an example issue, your case could be different from the one described in the below MATLAB answer. Once you pinpoint which part of your code is creating the slowdown, you can then take action to resolve the same.
Apart from this, I would recommend you to update your MATLAB version since newer versions come with performance enhancements and bug fixes. You can refer to the following MathWorks documentation for any help required for updating the software.
I hope this helps.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!