Recent

Author Topic: lazarus compiled program running too slow?  (Read 4031 times)

halflifezy

  • Jr. Member
  • **
  • Posts: 61
lazarus compiled program running too slow?
« on: January 21, 2012, 03:50:31 pm »
I found that lazarus compiled program running too slow
for example code below:
procedure computetime( );
var
  count:integer;
  deltatime:integer;
begin
  count:=0;
  deltatime:=GetTickCount();
  while(count<=900000)do
  begin
    Application.ProcessMessages();
    count:=count+1;
  end;
  deltatime:=GetTickCount()-deltatime;
  Memo1.Lines.Add(IntToStr(deltatime));
end;

running on delphi7 or xe2 with winxp only 37ms, but lazarus' program need
more than 1000ms.
my computer is amd3000+ 1G memory
will it can be better in future version?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: lazarus compiled program running too slow?
« Reply #1 on: January 22, 2012, 03:18:39 pm »
perhaps due do different implementation of Application.ProcessMessages(). Try not to use it whenever not really required (threads could be alternative)

halflifezy

  • Jr. Member
  • **
  • Posts: 61
Re: lazarus compiled program running too slow?
« Reply #2 on: January 23, 2012, 04:47:58 am »
well, thank you very much,problem sloved.
I use code:
procedure processmessage();
var
msg:TMSG;
begin
if (PeekMessage(@msg,0,0,0,PM_REMOVE)) then
 begin
 TranslateMessage(@msg);
 DispatchMessage(@msg);
 end;
end;


I use code above instead of Application.ProcessMessages then speed
run is better now.thank you a gain.
I love lazarus more and more now :)

Laksen

  • Hero Member
  • *****
  • Posts: 802
    • J-Software
Re: lazarus compiled program running too slow?
« Reply #3 on: January 23, 2012, 08:10:10 am »
The problem is of course that your new code won't work in any operating system but windows.

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: lazarus compiled program running too slow?
« Reply #4 on: January 23, 2012, 10:55:29 am »
It does sound like a problem that should use a separate thread.

 

TinyPortal © 2005-2018