Which is better in terms of performance, early binding or late binding in Delphi COM objects

In delphi, if you want to create a COM object, you can do this in two ways:

first early binding for example

uses MSScriptControl_TLB; // MS Script Control var obj: IScriptControl; begin obj := CreateOleObject('ScriptControl') as IScriptControl; .. .. obj.ExecuteStatement('Msgbox 1') end; 

Or you can do it like the following (last binding)

 var obj: OleVariant; begin obj := CreateOleObject('ScriptControl') ; obj.ExecuteStatement('Msgbox 1'); end; 

which one is better in terms of performance?

+6
source share
1 answer

Which one is better in terms of performance?

The early border is faster than the late. Processing the late binding method includes the following:

  • Search entry point on behalf of.
  • Build the parameters that must be passed to the method, and perform any necessary type conversions.
  • Function call.
  • Unmarshalling any parameters and return value.

Many of these steps are generally absent for early dispatch.

Of course, if a function does something significant at all, performance that is excellent when sending a method may not be detected.

+11
source

Source: https://habr.com/ru/post/948391/


All Articles