HP3000-L Archives

April 2004, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Dave Powell, MMfab" <[log in to unmask]>
Reply To:
Dave Powell, MMfab
Date:
Tue, 27 Apr 2004 14:49:47 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
Thanks to those who replied to my request for help optimizing:
    SETVAR  JUNK    ORD(RTF_CCTL)
    ECHO ![___!JUNK]!RTF_DATA
Unfortunately, the suggestions don't actually do the same thing as the
original code, although it might not be easy to see why without looking at
looking at the entire (long) command file.

The good news is, I get a about a 13% reduction in execution time for the
entire command file just by combining the 'setvar' above with an earlier
line that I did not include in the original post.  It still bugs me that
such a minor tweak makes such a big difference to a big routine that does
actual file I/O.

It turns out that
         SETVAR  JUNK    ORD(STR (RTF_REC,1,1))
         ECHO ![___!JUNK]!RTF_DATA
is quite a bit faster than
         SETVAR  RTF_CCTL    STR (RTF_REC,1,1)
         SETVAR  JUNK    ORD(RTF_CCTL)
         ECHO ![___!JUNK]!RTF_DATA
and the only surprise is why I didn't see it earlier.

Still tweaking the rest of the file, but execution time is already down to
bit less than half what I sent to a few sites last week.  In a another day
or two I hope to have a new version ready.

Some background/context for the above code.... It replaces HP
carriage-control codes with corresponding RTF codes, for example:
HP new page, chr(49)    becomes    '\page '
single-space, chr(129)    becomes    '\par '
double-space, chr(130)  becomes    '\par\par ',  etc.
In initialization, I set up a array of variables containing the RTF codes,
such as:  ___49 = '\page ', ___129 = '\par ', etc.
Then in the loop that processes each record, using form-feed as an example,
STR (RTF_REC,1,1) = 49, JUNK = 49, and the properly dereferenced,
![___!JUNK] is '\page ', which is what the output file must contain.  And it
is enough faster to be worth the extra trickiness, compared to the old
series of IFs & ELSEIFs.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2