Re: Performance RPG Figurative Constants versus Literals



Ah well if thats all you want to know, write three programs to execute the
code in the three different ways and put in a loop to do the code 1,000,000
times (or 10,000,000 or 100,000,000) until you get a difference in run
time... Then divide the difference in run time by the number of times round
the loop to get the difference - you might need a lot of decimal places on
your calculator though... :-)

Yea, already did that. Posted the results too;

http://groups.google.com/group/comp.sys.ibm.as400.misc/tree/browse_frm/thread/467cae01dbc70351/6bcd29ebfd5c1d38?rnum=1&q=edavid3001&_done=%2Fgroup%2Fcomp.sys.ibm.as400.misc%2Fbrowse_frm%2Fthread%2F467cae01dbc70351%2F3aaf3a328fbf16cc%3Flnk%3Dst%26q%3Dedavid3001%26rnum%3D1%26#doc_6211c694470782f4

In my case *blanks was a clear winner, but another did something very
simular and had no difference.

I suspect that there may be a few microseconds difference
in compilation times between the two methods,
but I also suspect that the compiled code will be
identical, so no performance difference when
running the resulting program.

I'm really after a definitive answer, not guesses. Hope that doesn't
sound harsh.

I would suspect that the compiler would store *blanks as a single byte
since it is a known figurative constant, and ' ' would require more
than a single byte since it has to store a value and a definition. So
it'd compile a byte or so bigger. I would also suspect that comparing
a 132 character string to a figurative constant would be quicker in the
microcode than comparing a 132 character string to another string or
costant. I know in VB it makes a huge difference. I have GB files I
do string comparisons over in VB. Proper string scanning can take a
process from taking a day to taking hours.

Fact is in RPG I don't know the answer, and was wonder if anyone did
know for a fact.

It is a given that going back into thousands of programs and switching
to using whichever is the best; *blanks or ' ' or @blanks, is not going
to make difference worth paying off. But I want to code new programs
with whichever is the best to use.

Last week I sat down with a program that runs every hour for ~400
seconds. I re-wrote pieces of it taking the process down to about 15
seconds to do the exact same work just by optimizing the code. SETLL
vs CHAIN. CHAIN/Update vs. SQL SELECT/Update. The CPU and disk
utilization dropped. Same way of doing the same thing, but different
ways work faster. *blanks versus ' ' will never result in that type
of savings.

The fact that jobs runs for 10 hours isn't the issue I'm asking about.
That 10 hours is tuned. The overhead is on the journal receiver
awaiting a PC to reply on most of these. So the delay causing 10 hours
is in the PC 3rd party software which we cannot touch. They are using
IBM Client Access API's to process journals which suck as they open a
new AS/400 connection each time they write to a journal. Over millions
of transactions the overhead of this is a killer. Many of the RPG
processing lines compare the DS of the results to blanks.

Thanks

.



Relevant Pages

  • Re: how to replace a substring in a string using C?
    ... Well spotted - no one else caught that one (I only picked it up after Dave ... strlen on the entire original string where possible - I posted a similar ... are some typical results (using the same compilation options as you except ... The optimisation of not calling strlen on the entire string cuts about 7% ...
    (comp.lang.c)
  • Re: inconsistent behavior of >FLOAT
    ... Accepting a string of blanks as 0 is a requirement in Forth-94. ... While>FLOAT is not required to treat a string of blanks as zero, ...
    (comp.lang.forth)
  • Re: inconsistent behavior of >FLOAT
    ... numeric data field filled with all blanks is interpreted as number 0. ... then an empty string will automatically resolve to the number 0. ... Numeric conversion functions in other languages behave similarly ... with respect to empty strings, ...
    (comp.lang.forth)
  • Re: A more efficient way
    ... > Is there a more efficient way of comparing a string to different words? ... the limit," 20.17's suggestion leads to hashing schemes which ...
    (comp.lang.c)
  • Re: if question
    ... >> performed before comparing. ... > and boolean is the simplest type. ... Why convert the string to boolean? ...
    (microsoft.public.scripting.jscript)