× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Larry Ducie wrote:
...
I mean, when you sit down and explain to somebody WHY in some situations
using const is much more efficient than value you find it difficult when
you're not really sure why yourself.

Larry, a demonstration is even better than an explanation. Here's a program that demonstrates the difference dramatically. The parameter tells it how many times to loop doing the calls.

Call it with a parameter of 1000, then 10000, 100000 etc until it registers a non-zero value for the CONST case.

I got these results:
CALL VALUECONST 100000
DSPLY value: 16 seconds | const: 0 seconds
CALL VALUECONST 1000000
DSPLY value: 169 seconds | const: 4 seconds

H dftactgrp(*no)
D byvalue pr
D bigparm 65535a varying value
D byconst pr
D bigparm 65535a varying const
D startTime s z
D endTime s z
D t1 s 5p 0
D t2 s 5p 0
D msg s 52a
D i s 10i 0
D valueconst pr extpgm('VALUECONST')
D ntimes 15p 5 const
D valueconst pi
D ntimes 15p 5 const
/free
startTime = %timestamp();
for i = 1 to %int(ntimes);
byvalue ('a');
endfor;
endTime = %timestamp();
t1 = %diff(endTime : startTime : *seconds);

startTime = %timestamp();
for i = 1 to %int(ntimes);
byconst ('a');
endfor;
endTime = %timestamp();
t2 = %diff(endTime : startTime : *seconds);
msg = 'value: ' + %editc(t1 : 'P') + ' seconds | '
+ 'const: ' + %editc(t2 : 'P') + ' seconds ';
dsply msg;
*inlr = '1';
/end-free

P byvalue b
D byvalue pi
D bigparm 65535a varying value
P byvalue e
P byconst b
D byconst pi
D bigparm 65535a varying const
P byconst e


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.