Recent

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

Pe3s

  • Full Member
  • ***
  • Posts: 146
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: 11632
Re: Compiled programs run slowly
« Reply #1 on: January 24, 2022, 02:46:44 pm »
Too much debug info. Compile as release.
Black themes should be banned.

Pe3s

  • Full Member
  • ***
  • Posts: 146
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: 7969
  • 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

  • Full Member
  • ***
  • Posts: 146
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: 4709
    • 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: 938
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 »
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

Warfley

  • Hero Member
  • *****
  • Posts: 856
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: 2836
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 on Windows 7 64bit.

 

TinyPortal © 2005-2018