CallFunction VS. CallFunctionFast
-
Codemonger
- Enthusiast

- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
CallFunction VS. CallFunctionFast
I did some tests in regards to the speed difference of CallFuntion and CallFunction Fast. Their is a huge difference in speed, CallFunctionFast is more than 10 times faster. Very cool. Anyway I was just wandering the speed of calling a function through a com object with the Interface command ? Any ideas of how comparable the speed is ?
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.
See yourself:
Its the same function called directly and in an object.
Disable the debugger to get realistic results!
I´ve tested on the oldest and slowest system available here, a PIII-600.
The difference is 1,5 seconds for 100 million calls.
On a dual PIII-1000 the difference is 0,9 seconds for 100 million calls.
Code: Select all
DisableDebugger ; !!!
Procedure XYZ()
ProcedureReturn 12
EndProcedure
Procedure XYZ2(*this)
ProcedureReturn 12
EndProcedure
Structure myObject
vTable.l
Function_XYZ.l
EndStructure
Interface myInterface
XYZ()
EndInterface
object.myObject
object\vTable = @object\Function_XYZ
object\Function_XYZ = @XYZ2()
obj.myInterface = object
#count = 99999999;9999999999
A$="The test begins and takes some time!"
B$="System is locked while the test runs... JUST WAIT!"
C$="The test *can* run several minutes!"
MessageRequester("ATTENTION!",A$+Chr(13)+B$+Chr(13)+C$,#MB_ICONEXCLAMATION)
Delay(500)
SetPriorityClass_(GetCurrentProcess_(),#REALTIME_PRIORITY_CLASS)
start = TimeGetTime_()
For a = 0 To #count
XYZ()
Next a
Test1 = TimeGetTime_()-start
start = TimeGetTime_()
For a = 0 To #count
obj\XYZ()
Next a
Test2 = TimeGetTime_()-start
SetPriorityClass_(GetCurrentProcess_(),#NORMAL_PRIORITY_CLASS)
A$ = "Result 1:"+StrU(Test1,#LONG)
B$ = "Result 2:"+StrU(Test2,#LONG)
MessageRequester("RESULT",A$+Chr(13)+B$,0)
Disable the debugger to get realistic results!
I´ve tested on the oldest and slowest system available here, a PIII-600.
The difference is 1,5 seconds for 100 million calls.
On a dual PIII-1000 the difference is 0,9 seconds for 100 million calls.
I want to compare as realistic and fair as i can, and this
means an object has always 1 parameter more than a procedure
that does the same.
If the procedure has 3 params, the same procedure in an object
has 4 params because ALWAYS '*this' is given to the object.
Here is the test again with 3 params for both procedures:
What Fred said is also true, you can test this out for yourself.
Without objects, you call function(handle,x,y) for example.
OOP-Style you call the same as obj\function(x,y) and the handle
is saved in a variable in the object itself.
means an object has always 1 parameter more than a procedure
that does the same.
If the procedure has 3 params, the same procedure in an object
has 4 params because ALWAYS '*this' is given to the object.
Here is the test again with 3 params for both procedures:
Code: Select all
DisableDebugger ; !!!
Procedure XYZ(a,b,c)
ProcedureReturn 12
EndProcedure
Procedure XYZ2(*this,a,b,c)
ProcedureReturn 12
EndProcedure
Structure myObject
vTable.l
Function_XYZ.l
EndStructure
Interface myInterface
XYZ(a,b,c)
EndInterface
object.myObject
object\vTable = @object\Function_XYZ
object\Function_XYZ = @XYZ2()
obj.myInterface = object
#count = 99999999;9999999999
A$="The test begins and takes some time!"
B$="System is locked while the test runs... JUST WAIT!"
C$="The test *can* run several minutes!"
MessageRequester("ATTENTION!",A$+Chr(13)+B$+Chr(13)+C$,#MB_ICONEXCLAMATION)
Delay(500)
SetPriorityClass_(GetCurrentProcess_(),#REALTIME_PRIORITY_CLASS)
start = TimeGetTime_()
For a = 0 To #count
XYZ(1,2,3)
Next a
Test1 = TimeGetTime_()-start
start = TimeGetTime_()
For a = 0 To #count
obj\XYZ(1,2,3)
Next a
Test2 = TimeGetTime_()-start
SetPriorityClass_(GetCurrentProcess_(),#NORMAL_PRIORITY_CLASS)
A$ = "Result 1:"+StrU(Test1,#LONG)
B$ = "Result 2:"+StrU(Test2,#LONG)
MessageRequester("RESULT",A$+Chr(13)+B$,0)Without objects, you call function(handle,x,y) for example.
OOP-Style you call the same as obj\function(x,y) and the handle
is saved in a variable in the object itself.

