[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Let versus Move
I was intrigued by this so also ran some tests.
This called a local procedure with 1 input parm and 12 output parms.
For 100,000 calls it took 10 elapsed seconds on win 95 (which is about the
same as CPU time).
100,000 calls to a global procedure took 7 seconds.
The key to this sort of test is that you only test one thing. So my
procedures don't do anything, particularly db access. They just move one
variable to another variable.
This looks like a 50% overhead. But keep in mind it's 0.0001 seconds per
local call vs 0.00007 seconds per global call. Unless you are calling
100,000 procedures in your program, it is probably not worth considering the
cpu overhead. The programmer debugging time is far more significant.
Most of pro's and con's have already been canvassed here, so I won't add to
that. But my experience in support has shown that whether you use local or
global procedures, it's much easier to debug if you only use one type or the
other. If you mix a lot of local and global procs in one large program,
debugging becomes much more difficult.
The timings and sqr source are attached
Steve.
-----Original Message-----
From: Ray Ontko [mailto:rayo@ONTKO.COM]
Sent: Tuesday, 31 August 1999 6:00
To: Multiple recipients of list SQR-USERS
Subject: Re: more info - performance with local procedures...
Clark,
> I welcome any additional evidence that either supports or debunks this
> theory. please attache code and results in postings - either here or
> directly to me.
I think of it this way. A local procedure is the same as a global
procedure in there is a MOVE for each parameter _before_ the call,
and a MOVE for each output parameter _after_ the call. Therefore,
we would expect a "local" procedure to behave the same as a "global"
assuming we're not passing parameters (or doing assignments before
and after the routine).
Here are the timings I got for 1,000,000 calls to a procedure
(global, local, or param) and the program I used to get these
timings. Basically, the issue is not whether it's a global
or local procedure, but whether or not you pass parameters
to it (or do the equivalent MOVEs).
Elaspsed CPU
global 22.258 10.950
local 22.211 10.970
param 35.186 17.290
noparam 34.209 16.530
My program follows:
begin-program
do main
end-program
begin-procedure main
move 'asdf' to $global_1
move 'qwer' to $global_2
move '' to $global_3
move 0 to #i
while #i < 1000000
#debuga do global_procedure
#debugb do local_procedure
#debugc do param_procedure( $global_1 , $global_2 , $global_3 )
#debugd move $global_1 to $p1
#debugd move $global_2 to $p2
#debugd move $global_3 to $p3
#debugd do no_param_procedure
#debugd move $p3 to $global_3
add 1 to #i
end-while
end-procedure
begin-procedure global_procedure
let $global_3 = $global_1 || $global_2
end-procedure
begin-procedure local_procedure local
let $_global_3 = $_global_1 || $_global_2
end-procedure
begin-procedure param_procedure( $p1 , $p2 , :$p3 )
let $p3 = $p1 || $p2
end-procedure
begin-procedure no_param_procedure
let $p3 = $p1 || $p2
end-procedure
----------------------------------------------------------------------
Ray Ontko | Ray Ontko & Co | "RO&C: data movers and shakers."
rayo@ontko.com | Richmond, In | See us at http://www.ontko.com/
------_=_NextPart_000_01BEF365.D59C8070
Content-Type: application/octet-stream;
name="test.sqr"
Content-Disposition: attachment;
filename="test.sqr"
begin-setup
declare-variable
date $start
end-declare
end-setup
begin-program
let $starttime='started global: '||edit(datenow(),'hh:mi:ss.nn')
print $starttime (1,1)
next-listing
let $start=datenow()
while (#count < 100000)
do globalp
add 1 to #count
end-while
let #elapsed=datediff(datenow(),$start,'second')
print 'elapsed ' (1,1)
print #elapsed ()
next-listing
move 0 to #count
let $starttime='started local: '||edit(datenow(),'hh:mi:ss.nn')
print $starttime (1,1)
next-listing
let $start=datenow()
while (#count < 100000)
do localp (#input,#return,#x1,#x2,#x3,#x4,#x5,#x6,#x7,#x8,#x9)
add 1 to #count
end-while
let #elapsed=datediff(datenow(),$start,'second')
print 'elapsed ' (1,1)
print #elapsed ()
next-listing
let $endtime='ended : '||edit(datenow(),'hh:mi:ss.nn')
print $endtime (1,1)
next-listing
end-program
begin-procedure globalp
move #gloablvar1 to #globalvar2
end-procedure
begin-procedure localp (#localvar1,:#localvar2,:#x1,:#x2,:#x3,:#x4,:#x5,:#x6,:#x7,:#x8,:#x9)
move #localvar1 to #localvar2
end-procedure