Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper technique for Functions/Procedures
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00095133
Message ID:
00095580
Views:
28
James,

Below is the listing. There are a couple of points that should be made.

First, I am not advocating that procedure files be used over objects. Rather that meeting design needs and maintenance requirements should be the overriding concern.

Second, the listing below uses no parameters for a reason. What I am attempting to measure is the call and return speed alone. That's the reason that the speed of the iteration structure is presented first. Were parameters included, they would impact the results, and perhaps prove misleading. This, of course, would depend on the number, data type, and, of course, how they were passed.
CLEAR
oFoo = CREATEOBJECT('FooClass')
* For reference. Message iteration speed
lnstart = SECONDS()
FOR lnj = 1 TO 10000
NEXT
lnfinish = SECONDS()
? "Elapsed time - no calls " + TRANSFORM(lnfinish - lnstart, '#.###')
* Measure straight procedure call
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  DO FooProc
NEXT
lnfinish = SECONDS()
? "Elapsed time - Procedure call " + TRANSFORM(lnfinish - lnstart, '#.###')
* Measure procedure called as a function
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  x = FooProc()
NEXT
lnfinish = SECONDS()
? "Elapsed time - Procedure as function call " + TRANSFORM(lnfinish - lnstart, '#.###')
* Measure function call
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  x = FooFunc()
NEXT
lnfinish = SECONDS()
? "Elapsed time - Function call " + TRANSFORM(lnfinish - lnstart, '#.###')
* Method call
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  oFoo.FooExec()
NEXT
lnfinish = SECONDS()
? "Elapsed time - Method call " + TRANSFORM(lnfinish - lnstart, '#.###')
* Method function call
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  x = oFoo.FooExec()
NEXT
lnfinish = SECONDS()
? "Elapsed time - Method function call " + TRANSFORM(lnfinish - lnstart, '#.###')

FUNCTION FooFunc
  LPARAMETER pFoo
  RETURN
ENDFUNC

PROCEDURE FooProc
  LPARAMETER pFoo
  RETURN
ENDPROC

DEFINE CLASS FooClass AS CUSTOM

  FUNCTION FooExec
    LPARAMETER pFoo
    RETURN
  ENDFUNC
ENDDEFINE
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform