|
Steve Richter wrote:
two procedures. both return a varying length string. Just the max size differs. 10a vs 32000a. pTestFunc1 b dTestFunc1 pi 32000a varying c return 'abc' p e pTestFunc2 b dTestFunc2 pi 10a varying c return 'abc' p e When I run them side by side in a timing loop, the 10a return value functions runs much quicker than the 32000a version. d ch80 s 80a varying c eval ch80 = TestFunc1 c eval ch80 = TestFunc2 30,000 times. 66 msec vs 2554 msec. I was hoping the run times would be comparable. When I assign a literal value to a varying char variable, the run times are the same, regardless of the size of the string. Any explanation why the run time difference?
The bottleneck is the RETURN statement. Unfortunately, W-Code doesn't recognize varying length character as a distinct data type, since W-Code represents a fairly low-level machine model. As a result, your procedure PTESTFUNC1 always returns 32002 bytes and your procedure PTESTFUNC2 always returns 12 bytes, regardless of the actual meaningful length of the return value. In all other places in the language, we can deal with just the exact number of bytes we need to, but RETURN has to copy all of the bytes of the variable. Bummer, eh? The lesson is to declare your string procedures with more modest return value lengths. Cheers! Hans
As an Amazon Associate we earn from qualifying purchases.
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.