For Programmers: Free Programming Magazines  


Home > Archive > Cobol > July 2005 > Re: Is it always possible to write a COBOL program using only 1 sentence per paragrap









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Is it always possible to write a COBOL program using only 1 sentence per paragrap
Rick Smith

2005-07-25, 10:02 pm


"Joe Zitzelberger" <joe_zitzelberger@nospam.com> wrote in message
news:joe_zitzelberger-2F5770.11542623072005@ispnews.usenetserver.com...
> In article <11due6mb9fhfac3@corp.supernews.com>,
> "Rick Smith" <ricksmith@mfi.net> wrote:
>
> <snip>
>
>
> Interesting, but you seem to have intentionally handicapped the loop
> version.
>
> Had you written it like this:
>
> "perform varying strlen-1 from length of str by -1"
>
> Then you would have had a flexible routine that will work in pretty much
> any case and could be reused frequently. This benefit would surely
> outweigh the trivial speed gain you would receive from the unrolled-loop
> version.


It is not clear to me that I "intentionally handicapped" anything.
I do not use LENGTH OF because it is non-standard and, with
the exception of COMP-5, I believe the extensions that I did use
(such as, unnamed paragraphs in sections, exit perform, and
partial expressions in the EVALUATE statement) are all
available in the 2002 standard. For flexibility, I would normally
write something like:

compute x = function length (str)
perform varying strlen from x by -1 ...

This is, at least, standard. However, flexibility was not a
consideration, code size was.

> Consider also that an optimizing compiler is likely to unroll the loop
> version for you if all of the necessary values are known at compile time.


The optimizing compiler I use does not unroll loops. In fact,
when I enabled some specific optimizations (OPTSPEED and
NOTRICKLE), the loop version slowed and the unrolled loop
sped up for lengths of 0 and 16, but slowed for a length of 32.
There is something happening that I do not yet, and may never,
understand; but the program was unimportant for all but one
reason.

> It is likely that the unrolled version of the code will never recover in
> runtime the amount of typing type the programmer spent writing it.


Which has nothing to do with the reason for the code. The
code was presented to demonstrate that *sometimes* larger
is faster. I was aware of this because I have unrolled loops
before and achieved speed gains on the order of 50 to 800
percent, in long running programs; that is, those programs
were the speed up was important (savings of hours per
execution, sometimes a hundred or more hours per year).



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com