Recent

Author Topic: Compiled programs run slowly  (Read 2628 times)

Pe3s

  • Hero Member
  • *****
  • Posts: 533
Compiled programs run slowly
« on: January 24, 2022, 02:37:45 pm »
What could be the reason why programs run slowly?

Thaddy

  • Hero Member
  • *****
  • Posts: 14169
  • Probably until I exterminate Putin.
Re: Compiled programs run slowly
« Reply #1 on: January 24, 2022, 02:46:44 pm »
Too much debug info. Compile as release.
Specialize a type, not a var.

Pe3s

  • Hero Member
  • *****
  • Posts: 533
Re: Compiled programs run slowly
« Reply #2 on: January 24, 2022, 03:43:51 pm »
compiled as released.
Lazarus 64 bit  2.0.12, FPC 3.2.0

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Compiled programs run slowly
« Reply #3 on: January 24, 2022, 04:00:16 pm »
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)

Pe3s

  • Hero Member
  • *****
  • Posts: 533
Re: Compiled programs run slowly
« Reply #4 on: January 24, 2022, 04:07:42 pm »
Program running outside IDE, DatabaseSQLite with one table and SQLite.dll

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: Compiled programs run slowly
« Reply #5 on: January 24, 2022, 06:46:04 pm »
Badly written SQL?

Bart

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Compiled programs run slowly
« Reply #6 on: January 24, 2022, 07:02:40 pm »
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?

« Last Edit: January 24, 2022, 07:04:37 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: Compiled programs run slowly
« Reply #7 on: January 24, 2022, 10:16:22 pm »
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

440bx

  • Hero Member
  • *****
  • Posts: 3921
Re: Compiled programs run slowly
« Reply #8 on: January 24, 2022, 11:08:04 pm »
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.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018