Lazarus
Programming => General => Topic started by: Pe3s on January 24, 2022, 02:37:45 pm
-
What could be the reason why programs run slowly?
-
Too much debug info. Compile as release.
-
compiled as released.
Lazarus 64 bit 2.0.12, FPC 3.2.0
-
Depends a lot on your program...
Try to run your program outside the IDE. Does the speed change? (That is more than 1 or 2 percent).
If it is (more or less) same as slow, then your code is 99.9% likely doing something that takes that much time. Or calling something that does. In that case, show the code (if you can / are permitted)
-
Program running outside IDE, DatabaseSQLite with one table and SQLite.dll
-
Badly written SQL?
Bart
-
If using timers, make sure that what ever they are doing in the timer can be completed before the next interval.
if unsure in the ontimer event disable the timer and enable it when the running code is finished. Similar principle for threads.
What is your CPU and Memory Doing in task manager?
-
The main reason for slow execution is most likely not bad optimization by the compiler or the tooling used, but it's most of the time simply inefficient algorithms and/or datastructures.
Everyone can just guess what might be the matter with your code, but the chances that anyone might guess correctly are pretty low. You should first see where you program is taking so long, and then see how you could optimize this. For this there are tools, so called profilers, that can measure how much time is spend in every function. See the Wiki page for further information: https://wiki.lazarus.freepascal.org/Profiling
-
What could be the reason why programs run slowly?
The only way to get an accurate answer to that kind of question is to profile the program. You do that and then you'll know where the program is spending its time. Anything else is educated guess work at best.