Recent

Author Topic: [Solved] Slow calls to DLL ?  (Read 4090 times)

halmariane

  • New Member
  • *
  • Posts: 30
[Solved] Slow calls to DLL ?
« on: May 21, 2013, 07:07:41 pm »
Hi everybody

All right?  :)

I am one doubt about the speed of calls to DLL from Lazarus.

In my project i have one DLL developed in C/C++. I have made all portings of headers, function calls (cdecl) and more to Lazarus. Really it's complicated to translate C to Pascal from my experience (macros, pointers, variable pass ...).

Ok, all performs right. There is no problem but .....

1.- The functions called from Lazarus (the execution) are more slow than C.
2.- If I compile the same calls in C/C++ then the execution is fast. (one simple "for do begin end")

I think that the guilty of the slow execution of Lazarus is for the CDECL calling convention. I fact, Lazarus has to convert Register calls to Cdecl calls.

Is that right?, is this correct?

Regards



« Last Edit: May 22, 2013, 10:13:02 am by halmariane »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7032
  • Debugger - SynEdit - and more
    • wiki
Re: Slow calls to DLL ?
« Reply #1 on: May 21, 2013, 08:25:14 pm »
Sounds unlikely...

Use -al to generate assembler from your pas, and check what is in there.

halmariane

  • New Member
  • *
  • Posts: 30
[Solved] Slow calls to DLL ?
« Reply #2 on: May 22, 2013, 09:00:33 am »
Sounds unlikely...

Use -al to generate assembler from your pas, and check what is in there.

Thank you Martin_fr (hello, how are you?.. long time ...)

I have recompiled with -al, and in fact, seems there is nothing wrong in the assembler code. The calls to the library and the loading of parameters are made in a few instructions.
Code: [Select]
leal -44(%ebp),%eax
pushl %eax
leal -40(%ebp),%eax
pushl %eax
movl $_$UMQTT$_Ld5,%eax
pushl %eax
movl -8(%ebp),%eax
pushl 1164(%eax)
movl U_$MQTTCLIENTLIBRARY_$$_MQTTCLIENT_PUBLISHMESSAGE,%eax
call *%eax
addl $16,%esp
movl %eax,-48(%ebp)
cmpl $10,-52(%ebp)
jl .Lj188

After testing that the problem is not the "slow calls to DLL" I did more investigations.

 :-[
Looking differences in my code between C - Pascal.... I did not realized that  i forgot to set one parameter in the Pascal Code.

 :-[
Now the calls are as faster as C/C++

Thanks and regards
« Last Edit: May 22, 2013, 10:12:44 am by halmariane »

 

TinyPortal © 2005-2018